def test_fetch_command_correctly(self, test_run, ctx, image_context, image_file): cmd = f"docker build --pull --file {image_file} " f"--tag test-image {image_context}" docker.build(ctx, name="test-image", context=image_context) test_run.assert_called_with(cmd)
def test_fetch_command_correctly_with_build_args(self, monkeypatch, test_run, ctx, image_context, image_file): monkeypatch.setenv("TEST_VARIABLE", "test_value") cmd = (f"docker build --pull --file {image_file} --tag test-image " f"--build-arg TEST_VARIABLE=test_value " f"{image_context}") docker.build(ctx, name="test-image", context=image_context, arg="TEST_VARIABLE") test_run.assert_called_with(cmd)
def test_missing_environment_variable_raises_error(self, ctx, image_context, image_file): with pytest.raises(AssertionError): docker.build(ctx, context=image_context, arg="BAD_VARIABLE")
def test_invalid_context_raises_error(self, ctx): with pytest.raises(utils.PathNotFound): docker.build(ctx, context="bad_context")