sdevani commented on a change in pull request #5251: [AIRFLOW-4135] Add Google
Cloud Build operator and hook
URL: https://github.com/apache/airflow/pull/5251#discussion_r283454349
##########
File path: tests/contrib/hooks/test_gcp_cloud_build_hook.py
##########
@@ -0,0 +1,126 @@
+import unittest
+from unittest import mock
+
+import six
+
+from airflow import AirflowException
+from airflow.contrib.hooks.gcp_cloud_build_hook import CloudBuildHook
+from tests.contrib.utils.base_gcp_mock import (
+ mock_base_gcp_hook_default_project_id,
+ mock_base_gcp_hook_no_default_project_id,
+)
+
+TEST_CREATE_BODY = {
+ "source": {"storageSource": {"bucket": "cloud-build-examples", "object":
"node-docker-example.tar.gz"}},
+ "steps": [
+ {"name": "gcr.io/cloud-builders/docker", "args": ["build", "-t",
"gcr.io/$PROJECT_ID/my-image", "."]}
+ ],
+ "images": ["gcr.io/$PROJECT_ID/my-image"],
+}
+
+TEST_BUILD = {"name": "build-name"}
+TEST_WAITING_OPERATION = {"done": False, "response": "response"}
+TEST_DONE_OPERATION = {"done": True, "response": "response"}
+TEST_ERROR_OPERATION = {"done": True, "response": "response", "error": "error"}
+
+
+class TestCloudBuildHookDefaultProjectId(unittest.TestCase):
+ hook = None
+
+ def setUp(self):
+ with mock.patch(
+
"airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook.__init__",
+ new=mock_base_gcp_hook_default_project_id,
+ ):
+ self.hook = CloudBuildHook(gcp_conn_id="test")
+
+
@mock.patch('airflow.contrib.hooks.gcp_cloud_build_hook.CloudBuildHook.get_conn')
+ def test_minimal_green_path(self, get_conn_mock):
Review comment:
nit: test_build_immediately_complete would be more descriptive of what this
is testing.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services