Skip to content

Commit bba823f

Browse files
authored
tests/unit/api_client: add test for TERMINATED+FAILED poll_for_completion
1 parent e4a11ca commit bba823f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/unit/api_client/test_job_runs_api.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,20 @@ def test_poll_for_completion__success(self, _, api, workspace_client):
203203
api.poll_for_completion("123")
204204

205205
workspace_client.jobs.get_run.assert_called_with(run_id=123)
206+
207+
@freezegun.freeze_time("2020-01-01")
208+
@patch("time.sleep")
209+
def test_poll_for_completion__failed(self, _, api, workspace_client):
210+
mock_run = Mock(spec=Run)
211+
mock_state = Mock(spec=RunState)
212+
mock_state.life_cycle_state = RunLifeCycleState.TERMINATED
213+
mock_state.result_state = RunResultState.FAILED
214+
mock_state.state_message = "notebook raised exception"
215+
mock_run.state = mock_state
216+
mock_run.run_id = 123
217+
workspace_client.jobs.get_run.return_value = mock_run
218+
219+
with pytest.raises(DbtRuntimeError) as exc:
220+
api.poll_for_completion("123")
221+
222+
assert "Python model run ended in result_state FAILED" in str(exc.value)

0 commit comments

Comments
 (0)