Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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"
Exemplo n.º 5
0
 def test_invalid_container_id_raises_error(self):
     task = WaitOnContainer()
     with pytest.raises(ValueError):
         task.run(container_id=None)
Exemplo n.º 6
0
 def test_empty_container_id_raises_error(self):
     task = WaitOnContainer()
     with pytest.raises(ValueError):
         task.run()