1414class TestUtilityFunctions :
1515 """Test utility functions used by selectors."""
1616
17- def test_count_unutilized_capabilities_no_unused (self ):
17+ def test_count_unutilized_capabilities_no_unused (self ) -> None :
1818 """Test counting when all requested resources are used."""
1919 agent = create_agent_info (
20- available_slots = {
20+ available_slots = ResourceSlot ( {
2121 "cpu" : Decimal ("8" ),
2222 "mem" : Decimal ("16384" ),
2323 "cuda.shares" : Decimal ("4" ),
24- }
24+ })
2525 )
2626 requested_slots = ResourceSlot ({
2727 "cpu" : Decimal ("2" ),
@@ -32,15 +32,15 @@ def test_count_unutilized_capabilities_no_unused(self):
3232 count = count_unutilized_capabilities (agent , requested_slots )
3333 assert count == 0
3434
35- def test_count_unutilized_capabilities_with_unused (self ):
35+ def test_count_unutilized_capabilities_with_unused (self ) -> None :
3636 """Test counting with some zero-requested resources."""
3737 agent = create_agent_info (
38- available_slots = {
38+ available_slots = ResourceSlot ( {
3939 "cpu" : Decimal ("8" ),
4040 "mem" : Decimal ("16384" ),
4141 "cuda.shares" : Decimal ("4" ),
4242 "tpu" : Decimal ("2" ),
43- }
43+ })
4444 )
4545 requested_slots = ResourceSlot ({
4646 "cpu" : Decimal ("2" ),
@@ -52,19 +52,19 @@ def test_count_unutilized_capabilities_with_unused(self):
5252 count = count_unutilized_capabilities (agent , requested_slots )
5353 assert count == 2 # cuda.shares and tpu are unutilized
5454
55- def test_count_unutilized_capabilities_unavailable_resources (self ):
55+ def test_count_unutilized_capabilities_unavailable_resources (self ) -> None :
5656 """Test that unavailable resources are not counted."""
5757 agent = create_agent_info (
58- available_slots = {
58+ available_slots = ResourceSlot ( {
5959 "cpu" : Decimal ("8" ),
6060 "mem" : Decimal ("16384" ),
6161 "cuda.shares" : Decimal ("4" ),
62- },
63- occupied_slots = {
62+ }) ,
63+ occupied_slots = ResourceSlot ( {
6464 "cpu" : Decimal ("0" ),
6565 "mem" : Decimal ("0" ),
6666 "cuda.shares" : Decimal ("4" ), # Fully occupied
67- },
67+ }) ,
6868 )
6969 requested_slots = ResourceSlot ({
7070 "cpu" : Decimal ("2" ),
@@ -75,7 +75,7 @@ def test_count_unutilized_capabilities_unavailable_resources(self):
7575 count = count_unutilized_capabilities (agent , requested_slots )
7676 assert count == 0 # cuda.shares is zero-requested but not available
7777
78- def test_order_slots_by_priority_basic (self ):
78+ def test_order_slots_by_priority_basic (self ) -> None :
7979 """Test basic slot ordering by priority."""
8080 requested_slots = ResourceSlot ({
8181 "cpu" : Decimal ("1" ),
@@ -88,7 +88,7 @@ def test_order_slots_by_priority_basic(self):
8888 result = order_slots_by_priority (requested_slots , priority_order )
8989 assert result == ["mem" , "cpu" , "cuda.shares" , "disk" ]
9090
91- def test_order_slots_by_priority_missing_priorities (self ):
91+ def test_order_slots_by_priority_missing_priorities (self ) -> None :
9292 """Test ordering when some slots are not in priority list."""
9393 requested_slots = ResourceSlot ({
9494 "cpu" : Decimal ("1" ),
@@ -104,19 +104,19 @@ def test_order_slots_by_priority_missing_priorities(self):
104104 # Non-priority slots should be sorted alphabetically
105105 assert result [1 :] == sorted (result [1 :])
106106
107- def test_order_slots_by_priority_empty_priority (self ):
107+ def test_order_slots_by_priority_empty_priority (self ) -> None :
108108 """Test ordering with empty priority list."""
109109 requested_slots = ResourceSlot ({
110110 "zebra" : Decimal ("1" ),
111111 "alpha" : Decimal ("2" ),
112112 "beta" : Decimal ("3" ),
113113 })
114- priority_order = []
114+ priority_order : list [ str ] = []
115115
116116 result = order_slots_by_priority (requested_slots , priority_order )
117117 assert result == ["alpha" , "beta" , "zebra" ] # Alphabetical order
118118
119- def test_order_slots_by_priority_nonexistent_priorities (self ):
119+ def test_order_slots_by_priority_nonexistent_priorities (self ) -> None :
120120 """Test that non-existent priority slots are ignored."""
121121 requested_slots = ResourceSlot ({
122122 "cpu" : Decimal ("1" ),
@@ -127,17 +127,17 @@ def test_order_slots_by_priority_nonexistent_priorities(self):
127127 result = order_slots_by_priority (requested_slots , priority_order )
128128 assert result == ["cpu" , "mem" ] # Only requested slots appear
129129
130- def test_agent_info_calculations (self ):
130+ def test_agent_info_calculations (self ) -> None :
131131 """Test that AgentInfo correctly calculates available resources."""
132132 agent = create_agent_info (
133- available_slots = {
133+ available_slots = ResourceSlot ( {
134134 "cpu" : Decimal ("16" ),
135135 "mem" : Decimal ("32768" ),
136- },
137- occupied_slots = {
136+ }) ,
137+ occupied_slots = ResourceSlot ( {
138138 "cpu" : Decimal ("10" ),
139139 "mem" : Decimal ("20480" ),
140- },
140+ }) ,
141141 )
142142
143143 free_slots = agent .available_slots - agent .occupied_slots
0 commit comments