daesung9511 commented on code in PR #70454:
URL: https://github.com/apache/airflow/pull/70454#discussion_r3651968658


##########
providers/google/tests/unit/google/cloud/operators/test_compute.py:
##########
@@ -190,71 +198,84 @@ def 
test_insert_instance_should_not_throw_ex_when_project_id_none(self, mock_hoo
             project_id=None,
         )
 
-    def test_insert_instance_should_throw_ex_when_missing_zone(self):
+    @mock.patch(COMPUTE_ENGINE_HOOK_PATH)
+    def test_insert_instance_should_throw_ex_when_missing_zone(self, 
mock_hook):
+        op = ComputeEngineInsertInstanceOperator(
+            resource_id=GCE_RESOURCE_ID,
+            body=GCE_INSTANCE_BODY_API_CALL,
+            zone="",
+            task_id=TASK_ID,
+            retry=RETRY,
+            timeout=TIMEOUT,
+            metadata=METADATA,
+            gcp_conn_id=GCP_CONN_ID,
+            impersonation_chain=IMPERSONATION_CHAIN,
+        )
         with pytest.raises(AirflowException, match=r"The required parameter 
'zone' is missing"):
-            ComputeEngineInsertInstanceOperator(
-                resource_id=GCE_RESOURCE_ID,
-                body=GCE_INSTANCE_BODY_API_CALL,
-                zone="",
-                task_id=TASK_ID,
-                retry=RETRY,
-                timeout=TIMEOUT,
-                metadata=METADATA,
-                gcp_conn_id=GCP_CONN_ID,
-                impersonation_chain=IMPERSONATION_CHAIN,
-            )
+            op.execute(context=mock.MagicMock())
+
+        mock_hook.assert_not_called()
 
-    def test_insert_instance_should_throw_ex_when_missing_resource_id(self):
+    @mock.patch(COMPUTE_ENGINE_HOOK_PATH)
+    def test_insert_instance_should_throw_ex_when_missing_resource_id(self, 
mock_hook):
+        op = ComputeEngineInsertInstanceOperator(
+            project_id=GCP_PROJECT_ID,
+            zone=GCE_ZONE,
+            body=GCE_INSTANCE_BODY_WITHOUT_NAME_API_CALL,
+            task_id=TASK_ID,
+            resource_id="",
+            gcp_conn_id=GCP_CONN_ID,
+            impersonation_chain=IMPERSONATION_CHAIN,
+        )
         with pytest.raises(
             AirflowException,
             match=r"The required parameters 'resource_id' and "
             r"body\['name'\] are missing\. Please, provide "
             r"at least one of them",
         ):
-            ComputeEngineInsertInstanceOperator(
-                project_id=GCP_PROJECT_ID,
-                zone=GCE_ZONE,
-                body=GCE_INSTANCE_BODY_WITHOUT_NAME_API_CALL,
-                task_id=TASK_ID,
-                resource_id="",
-                gcp_conn_id=GCP_CONN_ID,
-                impersonation_chain=IMPERSONATION_CHAIN,
-            )
+            op.execute(context=mock.MagicMock())
+
+        mock_hook.assert_not_called()
 
+    @pytest.mark.db_test
     @mock.patch(COMPUTE_ENGINE_HOOK_PATH)
-    def test_insert_instance_should_not_throw_ex_when_name_is_templated(self, 
mock_hook):
+    def test_insert_instance_should_not_throw_ex_when_name_is_templated(
+        self,
+        mock_hook,
+        create_task_instance_of_operator,
+        session,

Review Comment:
   Thank you for your feedback! I’ve removed the unused variable.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to