shahar1 commented on code in PR #60712:
URL: https://github.com/apache/airflow/pull/60712#discussion_r2701235434


##########
providers/google/tests/unit/google/cloud/operators/test_bigtable.py:
##########
@@ -584,66 +584,21 @@ def test_empty_attribute(self, mock_hook, 
missing_attribute, project_id, instanc
         mock_hook.assert_not_called()
 
     
@mock.patch("airflow.providers.google.cloud.operators.bigtable.BigtableHook")
-    def test_deleting_instance_that_doesnt_exists(self, mock_hook):
-        op = BigtableDeleteInstanceOperator(
-            project_id=PROJECT_ID,
-            instance_id=INSTANCE_ID,
-            task_id="id",
-            gcp_conn_id=GCP_CONN_ID,
-            impersonation_chain=IMPERSONATION_CHAIN,
-        )
-        mock_hook.return_value.delete_instance.side_effect = mock.Mock(
-            side_effect=google.api_core.exceptions.NotFound("Instance not 
found.")
-        )
-        op.execute(None)
-        mock_hook.assert_called_once_with(
-            gcp_conn_id=GCP_CONN_ID,
-            impersonation_chain=IMPERSONATION_CHAIN,
-        )
-        mock_hook.return_value.delete_instance.assert_called_once_with(
-            project_id=PROJECT_ID, instance_id=INSTANCE_ID
-        )
-
-    
@mock.patch("airflow.providers.google.cloud.operators.bigtable.BigtableHook")
-    def test_deleting_instance_that_doesnt_exists_empty_project_id(self, 
mock_hook):
-        op = BigtableDeleteInstanceOperator(
-            instance_id=INSTANCE_ID,
-            task_id="id",
-            gcp_conn_id=GCP_CONN_ID,
-            impersonation_chain=IMPERSONATION_CHAIN,
-        )
-        mock_hook.return_value.delete_instance.side_effect = mock.Mock(
-            side_effect=google.api_core.exceptions.NotFound("Instance not 
found.")
-        )
-        op.execute(None)
-        mock_hook.assert_called_once_with(
-            gcp_conn_id=GCP_CONN_ID,
-            impersonation_chain=IMPERSONATION_CHAIN,
-        )
-        mock_hook.return_value.delete_instance.assert_called_once_with(
-            project_id=None, instance_id=INSTANCE_ID
-        )
+    def test_delete_instance_when_instance_missing_does_not_fail(self, 
mock_hook):
+        # Simulate hook handling missing instance gracefully
+        mock_hook.return_value.delete_instance.return_value = None
 
-    
@mock.patch("airflow.providers.google.cloud.operators.bigtable.BigtableHook")
-    def test_different_error_reraised(self, mock_hook):
         op = BigtableDeleteInstanceOperator(
             project_id=PROJECT_ID,
             instance_id=INSTANCE_ID,
             task_id="id",
             gcp_conn_id=GCP_CONN_ID,
             impersonation_chain=IMPERSONATION_CHAIN,
         )
-        mock_hook.return_value.delete_instance.side_effect = mock.Mock(
-            side_effect=google.api_core.exceptions.GoogleAPICallError("error")
-        )
 
-        with pytest.raises(google.api_core.exceptions.GoogleAPICallError):
-            op.execute(None)
+        # Should NOT raise

Review Comment:
   Please delete this comment



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