def test_passes_args_to_watch_flow_run( self, mock_watch_flow_run, stream_logs, stream_states, MockFlowRunView ): wait_for_flow_run.run( "flow-run-id", stream_states=stream_states, stream_logs=stream_logs ) mock_watch_flow_run.assert_called_once_with( "flow-run-id", stream_states=stream_states, stream_logs=stream_logs )
def test_logs_include_flow_run_name_and_level(self, MockFlowRunView, mock_watch_flow_run, caplog): MockFlowRunView.from_flow_run_id.return_value.name = "fake-run-name" run_logs = [ FlowRunLog(timestamp=pendulum.now(), level=logging.INFO, message="Log message"), FlowRunLog(timestamp=pendulum.now(), level=logging.ERROR, message="Another log"), ] mock_watch_flow_run.return_value = run_logs wait_for_flow_run.run("flow-run-id") for record, run_log in zip(caplog.records, run_logs): assert record.levelno == run_log.level assert record.msg == f"Flow 'fake-run-name': {run_log.message}"
def test_returns_latest_flow_run_view(self, mock_watch_flow_run, MockFlowRunView): MockFlowRunView.from_flow_run_id( ).get_latest.return_value = "fake-return-value" result = wait_for_flow_run.run("flow-run-id") assert result == "fake-return-value"