def test_spawn_invalid_shutdown() -> None: manager = StateMachineManager() # Set manager into reset mode manager._mode = "Junk" # Spawn manager and ensure shutdowns manager.spawn() start_time = time.time() while True: time.sleep(0.1) if manager.is_shutdown: break assert manager._mode == modes.INVALID
def test_spawn_error_shutdown() -> None: manager = StateMachineManager() # Set manager into reset mode manager._mode = modes.ERROR # Spawn manager and ensure transitions to error mode manager.spawn() start_time = time.time() while True: time.sleep(0.1) if manager._mode == modes.ERROR: break # Ensure thread shutsdown message, status = manager.shutdown() assert status == 200 start_time = time.time() while True: time.sleep(0.1) if manager.is_shutdown: break
def test_run_error_mode_breaks_on_reset() -> None: manager = StateMachineManager() manager._mode = modes.RESET manager.run_error_mode() assert manager._mode == modes.RESET
def test_run_reset_to_init_mode() -> None: manager = StateMachineManager() manager._mode = modes.NORMAL manager.run_reset_mode() assert manager._mode == modes.INIT
def test_run_normal_to_shutdown_mode() -> None: manager = StateMachineManager() manager._mode = modes.SHUTDOWN manager.run_normal_mode() assert manager._mode == modes.SHUTDOWN
def test_new_transition_invalid_mode() -> None: manager = StateMachineManager() manager._mode = modes.NORMAL assert manager.new_transition(modes.RESET) == True assert manager._mode == modes.ERROR