Skip to content

Commit

Permalink
Try to minimize race conditions in unit tests involving events
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrondel committed Oct 15, 2024
1 parent 17666f3 commit 54fcee4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/test_atbuilding_csc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ async def test_open_one_vent(self):
async with self.make_csc(
initial_state=salobj.State.ENABLED, config_dir=None, simulation_mode=1
):
await self.assert_next_sample(
topic=self.remote.evt_ventGateState,
state=[VentGateState.CLOSED] * 4,
flush=False,
)
await self.remote.cmd_openVentGate.set_start(gate=[0, -1, -1, -1])
await asyncio.sleep(1)
await self.assert_next_sample(
Expand All @@ -52,11 +57,16 @@ async def test_open_vents(self):
async with self.make_csc(
initial_state=salobj.State.ENABLED, config_dir=None, simulation_mode=1
):
await self.assert_next_sample(
topic=self.remote.evt_ventGateState,
state=[VentGateState.CLOSED] * 4,
flush=False,
)
await self.remote.cmd_openVentGate.set_start(gate=[0, 1, 2, 3])
await self.assert_next_sample(
topic=self.remote.evt_ventGateState,
state=[VentGateState.OPENED] * 4,
flush=True,
flush=False,
)

async def test_close_one_vent(self):
Expand Down Expand Up @@ -189,8 +199,12 @@ async def test_drive_state(self):
async with self.make_csc(
initial_state=salobj.State.ENABLED, config_dir=None, simulation_mode=1
):
await self.assert_next_sample(
topic=self.remote.evt_extractionFanDriveState,
state=FanDriveState.STOPPED,
flush=False,
)
self.csc.mock_ctrl.fan_drive_state = FanDriveState.OPERATING
await asyncio.sleep(1)
await self.assert_next_sample(
topic=self.remote.evt_extractionFanDriveState,
state=FanDriveState.OPERATING,
Expand Down

0 comments on commit 54fcee4

Please sign in to comment.