harishkrao commented on a change in pull request #22213:
URL: https://github.com/apache/airflow/pull/22213#discussion_r830777747



##########
File path: tests/providers/google/cloud/hooks/test_pubsub.py
##########
@@ -371,7 +371,9 @@ def test_publish(self, mock_service):
             mock.call(topic=EXPANDED_TOPIC, data=message.get("data", b''), 
**message.get('attributes', {}))
             for message in TEST_MESSAGES
         ]
-        publish_method.has_calls(calls)
+        mock_calls_result = publish_method.mock_calls
+        result_refined = 
[mock_calls_result[0],mock_calls_result[2],mock_calls_result[4]]

Review comment:
       @uranusjr For this change, I had to filter the specific calls from the 
mock because there are additional calls being made. Filtering allows me to do 
an assert on the required calls.

##########
File path: tests/providers/google/cloud/transfers/test_sheets_to_gcs.py
##########
@@ -114,9 +114,11 @@ def test_execute(self, mock_upload_data, mock_xcom, 
mock_sheet_hook, mock_gcs_ho
         )
 
         calls = [mock.call(spreadsheet_id=SPREADSHEET_ID, range_=r) for r in 
RANGES]
-        mock_sheet_hook.return_value.get_values.has_calls(calls)
+        mock_sheet_hook.return_value.get_values.assert_has_calls(calls)
 
         calls = [mock.call(mock_gcs_hook, mock_sheet_hook, r, v) for r, v in 
zip(RANGES, data)]
-        mock_upload_data.has_calls(calls)
-
+        mock_upload_data.assert_called()

Review comment:
       @uranusjr I had to split the `assert_has_calls` into two tests because 
the mock_calls and the calls given in the list had differences, such as 
`GCSHook` vs `GCSHook()`. If you can suggest a better test/tests, I am happy to 
implemen them.
   Two assert tests I wrote are:
   
   1. Count the number of calls made by the mock and compare with the expected 
calls
   2. Was the mock called at least once? 




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