Exemplo n.º 1
0
    def test_repository_name_is_replaced(self, monkeypatch):
        task = ListImages(repository_name="original")

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

        task.run(repository_name="test")
        assert api.return_value.images.call_args[1]["name"] == "test"
Exemplo n.º 2
0
    def test_repository_name_run_value_is_used(self, monkeypatch):
        task = ListImages()

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

        task.run(repository_name="test")
        assert api.return_value.images.call_args[1]["name"] == "test"
Exemplo n.º 3
0
    def test_returns_list_images_value(self, monkeypatch, caplog):
        repo_name = "test repo"
        task = ListImages(repository_name=repo_name)

        api = MagicMock()
        expected_docker_output = [
            "A real image", "A second, equally real image"
        ]

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

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

            result = task.run()
            assert result == expected_docker_output

            assert len(caplog.records) == 2