@@ -419,6 +419,9 @@ async def run_test_battery_status_channel( # pylint: disable=too-many-arguments
419419 all_pool_result: result metric if all batteries in pool are working
420420 only_first_battery_result: result metric if only first battery in pool is
421421 working
422+
423+ Raises:
424+ ValueError: If the received message is not an instance of PowerMetrics or Sample.
422425 """
423426 assert len (batteries_in_pool ) == 2
424427
@@ -438,7 +441,13 @@ async def run_test_battery_status_channel( # pylint: disable=too-many-arguments
438441 msg = await asyncio .wait_for (
439442 battery_pool_metric_receiver .receive (), timeout = waiting_time_sec
440443 )
441- assert msg is None
444+ if isinstance (msg , PowerMetrics ):
445+ assert msg .inclusion_bounds is None
446+ assert msg .exclusion_bounds is None
447+ elif isinstance (msg , Sample ):
448+ assert msg .value is None
449+ else :
450+ raise ValueError ("Expected an instance of PowerMetrics or Sample" )
442451
443452 # One battery in uncertain state.
444453 await battery_status_sender .send (
@@ -662,7 +671,7 @@ async def run_capacity_test(setup_args: SetupArgs) -> None:
662671 await streamer .stop_streaming (batteries_in_pool [0 ])
663672 await asyncio .sleep (MAX_BATTERY_DATA_AGE_SEC + 0.2 )
664673 msg = await asyncio .wait_for (capacity_receiver .receive (), timeout = waiting_time_sec )
665- assert msg is None
674+ assert isinstance ( msg , Sample ) and msg . value is None
666675
667676 # One battery started sending data.
668677 latest_data = streamer .get_current_component_data (batteries_in_pool [0 ])
@@ -740,7 +749,7 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
740749 Scenario (
741750 batteries_in_pool [1 ],
742751 {"soc" : math .nan },
743- None ,
752+ Sample ( now , None ) ,
744753 ),
745754 Scenario (
746755 batteries_in_pool [1 ],
@@ -751,7 +760,7 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
751760 Scenario (
752761 batteries_in_pool [0 ],
753762 {"capacity" : 0 , "soc_lower_bound" : 10.0 , "soc_upper_bound" : 100.0 },
754- None ,
763+ Sample ( now , None ) ,
755764 wait_for_result = False ,
756765 ),
757766 # Test zero division error
@@ -795,7 +804,7 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
795804 await streamer .stop_streaming (batteries_in_pool [0 ])
796805 await asyncio .sleep (MAX_BATTERY_DATA_AGE_SEC + 0.2 )
797806 msg = await asyncio .wait_for (receiver .receive (), timeout = waiting_time_sec )
798- assert msg is None
807+ assert isinstance ( msg , Sample ) and msg . value is None
799808
800809 # One battery started sending data.
801810 latest_data = streamer .get_current_component_data (batteries_in_pool [0 ])
@@ -885,7 +894,11 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
885894 "active_power_inclusion_upper_bound" : 9000 ,
886895 "active_power_exclusion_upper_bound" : 250 ,
887896 },
888- expected_result = None ,
897+ expected_result = PowerMetrics (
898+ now ,
899+ None ,
900+ None ,
901+ ),
889902 wait_for_result = False ,
890903 ),
891904 Scenario (
@@ -995,7 +1008,11 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
9951008 "power_inclusion_lower_bound" : math .nan ,
9961009 "power_inclusion_upper_bound" : math .nan ,
9971010 },
998- None ,
1011+ PowerMetrics (
1012+ now ,
1013+ None ,
1014+ None ,
1015+ ),
9991016 ),
10001017 Scenario (
10011018 batteries_in_pool [0 ],
@@ -1121,7 +1138,11 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
11211138 await streamer .stop_streaming (bat_inv_map [batteries_in_pool [1 ]])
11221139 await asyncio .sleep (MAX_BATTERY_DATA_AGE_SEC + 0.2 )
11231140 msg = await asyncio .wait_for (receiver .receive (), timeout = waiting_time_sec )
1124- assert msg is None
1141+ assert (
1142+ isinstance (msg , PowerMetrics )
1143+ and msg .inclusion_bounds is None
1144+ and msg .exclusion_bounds is None
1145+ )
11251146
11261147 # One battery started sending data.
11271148 latest_data = streamer .get_current_component_data (batteries_in_pool [0 ])
@@ -1201,7 +1222,7 @@ async def run_temperature_test( # pylint: disable=too-many-locals
12011222 Scenario (
12021223 bat_1 ,
12031224 {"temperature" : math .nan },
1204- None ,
1225+ Sample ( now , None ) ,
12051226 ),
12061227 Scenario (
12071228 bat_0 ,
@@ -1238,7 +1259,7 @@ async def run_temperature_test( # pylint: disable=too-many-locals
12381259 await streamer .stop_streaming (bat_0 )
12391260 await asyncio .sleep (MAX_BATTERY_DATA_AGE_SEC + 0.2 )
12401261 msg = await asyncio .wait_for (receiver .receive (), timeout = waiting_time_sec )
1241- assert msg is None
1262+ assert isinstance ( msg , Sample ) and msg . value is None
12421263
12431264 # one battery started sending data.
12441265 latest_data = streamer .get_current_component_data (bat_1 )
0 commit comments