55import copy
66import json
77from typing import Any
8+ from unittest .mock import ANY
89
910import pytest
1011
@@ -31,7 +32,12 @@ def test_check_status(full_status: FullStatus, kwargs):
3132 "mysql-test-app/0" ,
3233 "mysql-test-app/1" ,
3334 },
34- set (),
35+ {
36+ "grafana-agent-k8s/0" ,
37+ "hexanator/0" ,
38+ "mysql-test-app/0" ,
39+ "mysql-test-app/1" ,
40+ },
3541 )
3642
3743
@@ -44,7 +50,7 @@ def test_check_status_missing_app(full_status: FullStatus, kwargs):
4450def test_check_status_is_selective (full_status : FullStatus , kwargs ):
4551 kwargs ["apps" ] = ["hexanator" ]
4652 status = check (full_status , ** kwargs )
47- assert status == CheckStatus ({"hexanator/0" }, {"hexanator/0" }, set () )
53+ assert status == CheckStatus ({"hexanator/0" }, {"hexanator/0" }, { "hexanator/0" } )
4854
4955
5056def test_no_apps (full_status : FullStatus , kwargs ):
@@ -80,33 +86,21 @@ def test_app_error(response: dict[str, Any], kwargs):
8086 assert "big problem" in str (e )
8187
8288
83- def test_exact_count (response : dict [str , Any ], kwargs ):
84- units = response ["response" ]["applications" ]["hexanator" ]["units" ]
85- units ["hexanator/1" ] = units ["hexanator/0" ]
86-
87- kwargs ["apps" ] = ["hexanator" ]
88-
89- status = check (convert (response ), ** kwargs )
90- assert status == CheckStatus (
91- {"hexanator/0" , "hexanator/1" }, {"hexanator/0" , "hexanator/1" }, set ()
92- )
93-
94-
9589def test_ready_units (full_status : FullStatus , kwargs ):
9690 kwargs ["apps" ] = ["mysql-test-app" ]
9791 status = check (full_status , ** kwargs )
9892 assert status == CheckStatus (
9993 {"mysql-test-app/0" , "mysql-test-app/1" },
10094 {"mysql-test-app/0" , "mysql-test-app/1" },
101- set () ,
95+ { "mysql-test-app/0" , "mysql-test-app/1" } ,
10296 )
10397
10498
10599def test_active_units (full_status : FullStatus , kwargs ):
106100 kwargs ["apps" ] = ["mysql-test-app" ]
107101 kwargs ["status" ] = "active"
108102 status = check (full_status , ** kwargs )
109- assert status == CheckStatus ({"mysql-test-app/0" , "mysql-test-app/1" }, set (), set () )
103+ assert status == CheckStatus ({"mysql-test-app/0" , "mysql-test-app/1" }, set (), ANY )
110104
111105
112106def test_ready_unit_requires_idle_agent (response : dict [str , Any ], kwargs ):
@@ -118,9 +112,11 @@ def test_ready_unit_requires_idle_agent(response: dict[str, Any], kwargs):
118112 kwargs ["status" ] = "active"
119113
120114 status = check (convert (response ), ** kwargs )
121- assert status
122- assert status .units == {"hexanator/0" , "hexanator/1" }
123- assert status .ready_units == {"hexanator/0" }
115+ assert status == CheckStatus (
116+ {"hexanator/0" , "hexanator/1" },
117+ {"hexanator/0" , "hexanator/1" },
118+ {"hexanator/0" },
119+ )
124120
125121
126122def test_ready_unit_requires_workload_status (response : dict [str , Any ], kwargs ):
@@ -132,7 +128,7 @@ def test_ready_unit_requires_workload_status(response: dict[str, Any], kwargs):
132128 kwargs ["status" ] = "active"
133129
134130 status = check (convert (response ), ** kwargs )
135- assert status == CheckStatus ({"hexanator/0" , "hexanator/1" }, {"hexanator/0" }, set () )
131+ assert status == CheckStatus ({"hexanator/0" , "hexanator/1" }, {"hexanator/0" }, ANY )
136132
137133
138134def test_agent_error (response : dict [str , Any ], kwargs ):
@@ -182,7 +178,7 @@ def test_machine_ok(response: dict[str, Any], kwargs):
182178 kwargs ["raise_on_error" ] = True
183179
184180 status = check (convert (response ), ** kwargs )
185- assert status == CheckStatus ({"hexanator/0" }, {"hexanator/0" }, set () )
181+ assert status == CheckStatus ({"hexanator/0" }, {"hexanator/0" }, ANY )
186182
187183
188184def test_machine_error (response : dict [str , Any ], kwargs ):
@@ -244,7 +240,7 @@ def test_maintenance(response: dict[str, Any], kwargs):
244240 kwargs ["status" ] = "maintenance"
245241
246242 status = check (convert (response ), ** kwargs )
247- assert status == CheckStatus ({"hexanator/0" }, {"hexanator/0" }, set () )
243+ assert status == CheckStatus ({"hexanator/0" }, {"hexanator/0" }, ANY )
248244
249245
250246@pytest .fixture
0 commit comments