daesung9511 commented on code in PR #70454:
URL: https://github.com/apache/airflow/pull/70454#discussion_r3651972166
##########
providers/google/tests/unit/google/cloud/operators/test_compute.py:
##########
@@ -516,37 +580,48 @@ def
test_delete_instance_should_execute_successfully(self, mock_hook):
zone=GCE_ZONE,
)
- def test_delete_instance_should_throw_ex_when_missing_zone(self):
- with pytest.raises(AirflowException, match=r"The required parameter
'zone' is missing"):
- ComputeEngineDeleteInstanceOperator(
- resource_id=GCE_RESOURCE_ID,
- zone="",
- task_id=TASK_ID,
- retry=RETRY,
- timeout=TIMEOUT,
- metadata=METADATA,
- gcp_conn_id=GCP_CONN_ID,
- impersonation_chain=IMPERSONATION_CHAIN,
- )
+ @mock.patch(COMPUTE_ENGINE_HOOK_PATH)
+ def test_delete_instance_should_throw_ex_when_missing_zone(self,
mock_hook):
+ op = ComputeEngineDeleteInstanceOperator(
+ project_id=GCP_PROJECT_ID,
+ zone="",
+ resource_id=GCE_RESOURCE_ID,
+ task_id=TASK_ID,
+ gcp_conn_id=GCP_CONN_ID,
+ impersonation_chain=IMPERSONATION_CHAIN,
+ )
+
+ with pytest.raises(
+ AirflowException,
+ match=r"The required parameter 'zone' is missing",
+ ):
+ op.execute(context=mock.MagicMock())
+
+ mock_hook.assert_not_called()
- def test_delete_instance_should_throw_ex_when_missing_resource_id(self):
+ @mock.patch(COMPUTE_ENGINE_HOOK_PATH)
+ def test_delete_instance_should_throw_ex_when_missing_resource_id(self,
mock_hook):
+ op = ComputeEngineDeleteInstanceOperator(
+ resource_id="",
+ zone=GCE_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
'resource_id' is missing"):
- ComputeEngineDeleteInstanceOperator(
- resource_id="",
- zone=GCE_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_hook.MagicMock())
Review Comment:
I’ve fixed it as you suggested.
--
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]