Esempio n. 1
0
    def test_image_and_repository_is_replaced(self, monkeypatch):
        task = TagImage(image="original", repository="original")

        api = MagicMock()
        monkeypatch.setattr("docker.APIClient", api)

        task.run(image="test", repository="test")
        assert api.return_value.tag.call_args[1]["image"] == "test"
        assert api.return_value.tag.call_args[1]["repository"] == "test"
Esempio n. 2
0
    def test_image_and_repository_run_value_is_used(self, monkeypatch):
        task = TagImage()

        api = MagicMock()
        monkeypatch.setattr("prefect.tasks.docker.containers.docker.APIClient",
                            api)

        task.run(image="test", repository="test")
        assert api.return_value.tag.call_args[1]["image"] == "test"
        assert api.return_value.tag.call_args[1]["repository"] == "test"
Esempio n. 3
0
    def test_returns_tag_value(self, monkeypatch, caplog):
        image = "an image thats going to get tagged"
        task = TagImage(image=image)
        expected_docker_output = image
        api = MagicMock()
        api.return_value.tag = MagicMock(return_value=expected_docker_output)
        monkeypatch.setattr("docker.APIClient", api)

        with caplog.at_level(logging.DEBUG, logger=task.logger.name):

            actual = task.run(image=image, repository="test")
            assert actual == expected_docker_output
Esempio n. 4
0
 def test_invalid_image_raises_error(self):
     task = TagImage()
     with pytest.raises(ValueError):
         task.run(image=None)
Esempio n. 5
0
 def test_empty_image_raises_error(self):
     task = TagImage()
     with pytest.raises(ValueError):
         task.run()