示例#1
0
    def test_all_containers_init_value_is_used(self, monkeypatch):
        task = ListContainers(all_containers=True)

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

        task.run()
        assert api.return_value.containers.call_args[1]["all"]
示例#2
0
    def test_all_containers_is_replaced(self, monkeypatch):
        task = ListContainers(all_containers=False)

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

        task.run(all_containers=True)
        assert api.return_value.containers.call_args[1]["all"]
示例#3
0
 def test_filled_initialization(self):
     task = ListContainers(all_containers=True,
                           filters={"name": "test"},
                           docker_server_url="test")
     assert task.all_containers == True
     assert task.filters == {"name": "test"}
     assert task.docker_server_url == "test"
示例#4
0
    def test_logs_twice_on_success(self, monkeypatch, caplog):

        task = ListContainers(all_containers=False)

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

        self.assert_logs_twice_on_success(task, caplog)
示例#5
0
    def test_logs_once_on_docker_api_failure(self, monkeypatch, caplog):
        task = ListContainers(all_containers=False)

        api = MagicMock()
        list_containers_mock = MagicMock(
            side_effect=docker.errors.DockerException(
                "A docker specific exception"))
        api.return_value.containers = list_containers_mock
        monkeypatch.setattr("docker.APIClient", api)
        self.assert_logs_once_on_docker_api_failure(task, caplog)
示例#6
0
 def test_empty_initialization(self):
     task = ListContainers()
     assert not task.all_containers
     assert not task.filters
     assert task.docker_server_url == "unix:///var/run/docker.sock"