def test_shutdown_execute_conditional(): """Test the conditional execution (or visit) of the Shutdown class.""" true_action = Shutdown(condition=IfCondition('True')) false_action = Shutdown(condition=IfCondition('False')) context = LaunchContext() assert context._event_queue.qsize() == 0 assert false_action.visit(context) is None assert context._event_queue.qsize() == 0 assert true_action.visit(context) is None assert context._event_queue.qsize() == 1 event = context._event_queue.get_nowait() assert isinstance(event, ShutdownEvent)
def test_shutdown_reason(): """Test the execute (or visit) of a Shutdown class that has a reason.""" action = Shutdown(reason='test reason') context = LaunchContext() assert action.visit(context) is None assert context._event_queue.qsize() == 1 event = context._event_queue.get_nowait() assert isinstance(event, ShutdownEvent) assert event.reason == 'test reason'
def test_shutdown_execute(): """Test the execute (or visit) of the Shutdown class.""" action = Shutdown() context = LaunchContext() assert context._event_queue.qsize() == 0 assert action.visit(context) is None assert context._event_queue.qsize() == 1 event = context._event_queue.get_nowait() assert isinstance(event, ShutdownEvent)