def test_repository_is_replaced(self, monkeypatch): task = PushImage(repository="original") api = MagicMock() monkeypatch.setattr("docker.APIClient", api) task.run(repository="test") assert api.return_value.push.call_args[1]["repository"] == "test"
def test_repository_run_value_is_used(self, monkeypatch): task = PushImage() api = MagicMock() monkeypatch.setattr("prefect.tasks.docker.containers.docker.APIClient", api) task.run(repository="test") assert api.return_value.push.call_args[1]["repository"] == "test"
def test_returns_push_value(self, monkeypatch, caplog): task = PushImage(repository="original") api = MagicMock() expected_docker_output = "An example push API response" api.return_value.push = MagicMock(return_value=expected_docker_output) monkeypatch.setattr("docker.APIClient", api) with caplog.at_level(logging.DEBUG, logger=task.logger.name): result = task.run(repository="test") assert result == expected_docker_output
def test_invalid_repository_raises_error(self): task = PushImage() with pytest.raises(ValueError): task.run(repository=None)
def test_empty_repository_raises_error(self): task = PushImage() with pytest.raises(ValueError): task.run()