Skip to content

Commit 65c028e

Browse files
committed
Sort set_power call order in battery pool tests, before checking
This is because since the m:n battery-inverter ordering was merged, the PowerDistributingActor is no longer calling microgridApiClient.set_power in sequential order. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 201f3d3 commit 65c028e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/timeseries/_battery_pool/test_battery_pool_control_methods.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def test_case_1(
198198
)
199199

200200
assert set_power.call_count == 4
201-
assert set_power.call_args_list == [
201+
assert sorted(set_power.call_args_list) == [
202202
mocker.call(inv_id, 250.0)
203203
for inv_id in mocks.microgrid.battery_inverter_ids
204204
]
@@ -233,7 +233,7 @@ async def side_effect(inv_id: int, _: float) -> None:
233233
),
234234
)
235235
assert set_power.call_count == 4
236-
assert set_power.call_args_list == [
236+
assert sorted(set_power.call_args_list) == [
237237
mocker.call(inv_id, 25.0) for inv_id in mocks.microgrid.battery_inverter_ids
238238
]
239239
set_power.reset_mock()
@@ -251,7 +251,7 @@ async def side_effect(inv_id: int, _: float) -> None:
251251
# There should be an automatic retry.
252252
set_power.side_effect = None
253253
assert set_power.call_count == 4
254-
assert set_power.call_args_list == [
254+
assert sorted(set_power.call_args_list) == [
255255
mocker.call(inv_id, 25.0) for inv_id in mocks.microgrid.battery_inverter_ids
256256
]
257257
self._assert_report(
@@ -294,7 +294,7 @@ async def test_case_2(self, mocks: Mocks, mocker: MockerFixture) -> None:
294294
await bounds_1_rx.receive(), power=1000.0, lower=-2000.0, upper=2000.0
295295
)
296296
assert set_power.call_count == 2
297-
assert set_power.call_args_list == [
297+
assert sorted(set_power.call_args_list) == [
298298
mocker.call(inv_id, 500.0)
299299
for inv_id in mocks.microgrid.battery_inverter_ids[:2]
300300
]
@@ -305,7 +305,7 @@ async def test_case_2(self, mocks: Mocks, mocker: MockerFixture) -> None:
305305
await bounds_2_rx.receive(), power=1000.0, lower=-2000.0, upper=2000.0
306306
)
307307
assert set_power.call_count == 2
308-
assert set_power.call_args_list == [
308+
assert sorted(set_power.call_args_list) == [
309309
mocker.call(inv_id, 500.0)
310310
for inv_id in mocks.microgrid.battery_inverter_ids[2:]
311311
]
@@ -347,7 +347,7 @@ async def test_case_3(self, mocks: Mocks, mocker: MockerFixture) -> None:
347347
)
348348

349349
assert set_power.call_count == 4
350-
assert set_power.call_args_list == [
350+
assert sorted(set_power.call_args_list) == [
351351
mocker.call(inv_id, -250.0)
352352
for inv_id in mocks.microgrid.battery_inverter_ids
353353
]
@@ -365,6 +365,6 @@ async def test_case_3(self, mocks: Mocks, mocker: MockerFixture) -> None:
365365
)
366366

367367
assert set_power.call_count == 4
368-
assert set_power.call_args_list == [
368+
assert sorted(set_power.call_args_list) == [
369369
mocker.call(inv_id, 0.0) for inv_id in mocks.microgrid.battery_inverter_ids
370370
]

0 commit comments

Comments
 (0)