Skip to content

Commit

Permalink
Fix time dependant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oysand committed Jan 15, 2025
1 parent 78762d0 commit 90099e2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/isar/state_machine/test_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,28 @@ def test_state_machine_with_unsuccessful_collection(

def test_state_machine_with_successful_mission_stop(
injector: Injector,
mocker: MockerFixture,
state_machine_thread: StateMachineThread,
) -> None:
state_machine_thread.start()

mission: Mission = Mission(name="Dummy misson", tasks=[MockTask.take_image()])
mocker.patch.object(MockRobot, "task_status", return_value=TaskStatus.InProgress)

scheduling_utilities: SchedulingUtilities = injector.get(SchedulingUtilities)
scheduling_utilities.start_mission(mission=mission, initial_pose=None)
time.sleep(0.11) # Slightly more than the StateMachine sleep time
scheduling_utilities.stop_mission()

assert state_machine_thread.state_machine.transitions_list == deque(
[States.Idle, States.Initialize, States.Initiate, States.Stop, States.Idle]
[
States.Idle,
States.Initialize,
States.Initiate,
States.Monitor,
States.Stop,
States.Idle,
]
)


Expand All @@ -264,6 +274,7 @@ def test_state_machine_with_unsuccessful_mission_stop(
state_machine_thread.start()

scheduling_utilities.start_mission(mission=mission, initial_pose=None)
time.sleep(0.11) # Slightly more than the StateMachine sleep time
scheduling_utilities.stop_mission()

expected_log = (
Expand All @@ -272,7 +283,14 @@ def test_state_machine_with_unsuccessful_mission_stop(
)
assert expected_log in caplog.text
assert state_machine_thread.state_machine.transitions_list == deque(
[States.Idle, States.Initialize, States.Initiate, States.Stop, States.Idle]
[
States.Idle,
States.Initialize,
States.Initiate,
States.Monitor,
States.Stop,
States.Idle,
]
)


Expand Down

0 comments on commit 90099e2

Please sign in to comment.