amoghrajesh commented on code in PR #54083:
URL: https://github.com/apache/airflow/pull/54083#discussion_r2254256563


##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/hooks/test_kubernetes.py:
##########
@@ -437,11 +439,12 @@ def test_prefixed_names_still_work(self, mock_get_client):
             mock_get_client.assert_called_with(cluster_context="test")
             assert kubernetes_hook.get_namespace() == "test"
 
-    def test_missing_default_connection_is_ok(self, remove_default_conn):
+    def test_missing_default_connection_is_ok(self, remove_default_conn, 
mock_supervisor_comms):
         # prove to ourselves that the default conn doesn't exist
         k8s_conn_exists = 
os.environ.get(f"AIRFLOW_CONN_{DEFAULT_CONN_ID.upper()}")
         assert k8s_conn_exists is None
 
+        mock_supervisor_comms.send.side_effect = 
[ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)] * 2

Review Comment:
   Yeah i do not like it either, worth rethinking it



##########
providers/google/tests/unit/google/cloud/operators/test_dataflow.py:
##########
@@ -767,10 +776,11 @@ def test_invalid_project_id(self):
             
DataflowDeletePipelineOperator(**init_kwargs).execute(mock.MagicMock())
 
     @pytest.mark.db_test
-    def test_invalid_location(self):
+    def test_invalid_location(self, mock_supervisor_comms):
         """
         Test that AirflowException is raised if Delete Operator is not given a 
location.
         """
+        mock_supervisor_comms.send.return_value = 
ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)

Review Comment:
   > 1: is this a db test anymore?
   
   No, not a db test anymore. Removing that.
   
   
   
   
   
   > 2: this pattern is so common I wonder if it's worth doing this instead
   > 
   > ```python
   >     @pytest.mark.db_test
   >     @pytest.mark.use_fixture("connection_not_found")
   >     def test_invalid_location(self):
   >         """
   >         Test that AirflowException is raised if Delete Operator is not 
given a location.
   >         """
   > ```
   > 
   > That way the detail of how/what is mocked isn't repeated 100s(?) of times? 
And we have a fixture once that does this
   
   Yeah sounds like a good idea.
   
   



##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/hooks/test_kubernetes.py:
##########
@@ -437,11 +439,12 @@ def test_prefixed_names_still_work(self, mock_get_client):
             mock_get_client.assert_called_with(cluster_context="test")
             assert kubernetes_hook.get_namespace() == "test"
 
-    def test_missing_default_connection_is_ok(self, remove_default_conn):
+    def test_missing_default_connection_is_ok(self, remove_default_conn, 
mock_supervisor_comms):
         # prove to ourselves that the default conn doesn't exist
         k8s_conn_exists = 
os.environ.get(f"AIRFLOW_CONN_{DEFAULT_CONN_ID.upper()}")
         assert k8s_conn_exists is None
 
+        mock_supervisor_comms.send.side_effect = 
[ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)] * 2

Review Comment:
   Maybe its worth building a fixture that catches the call and returns 
accordingly.



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