def test_spawn_shutdown() -> None: manager = StateMachineManager() # Spawn manager and ensure transitions to normal mode manager.spawn() start_time = time.time() while True: time.sleep(0.1) if manager._mode == modes.NORMAL: 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_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_create_reset_event() -> None: manager = StateMachineManager() # Spawn manager and ensure transitions to normal mode manager.spawn() start_time = time.time() while True: time.sleep(0.1) if manager._mode == modes.NORMAL: break # Create reset event request = {"type": events.RESET} message, status = manager.create_event(request) assert status == 200 # Shutdown manager an 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