def test_doesnt_raise_for_nonzero_status(self, monkeypatch): task = WaitOnContainer(container_id="noise", raise_on_exit_code=False) api = MagicMock() monkeypatch.setattr("docker.APIClient", api) api.return_value.wait.return_value = {"StatusCode": 1, "Error": "oops!"} task.run()
def test_raises_for_error(self, monkeypatch): task = WaitOnContainer(container_id="noise") api = MagicMock() monkeypatch.setattr("docker.APIClient", api) api.return_value.wait.return_value = {"Error": "oops!"} with pytest.raises(FAIL): task.run()
def test_raises_for_nonzero_status(self, monkeypatch): task = WaitOnContainer(container_id="noise") api = MagicMock() monkeypatch.setattr("docker.APIClient", api) api.return_value.wait.return_value = {"StatusCode": 1} with pytest.raises(FAIL): task.run()
def test_container_id_run_value_is_used(self, monkeypatch): task = WaitOnContainer(container_id="init") api = MagicMock() monkeypatch.setattr("docker.APIClient", api) api.return_value.wait.return_value = {} task.run(container_id="test") assert api.return_value.wait.call_args[1]["container"] == "test"
def test_invalid_container_id_raises_error(self): task = WaitOnContainer() with pytest.raises(ValueError): task.run(container_id=None)
def test_empty_container_id_raises_error(self): task = WaitOnContainer() with pytest.raises(ValueError): task.run()