gopidesupavan commented on code in PR #42080:
URL: https://github.com/apache/airflow/pull/42080#discussion_r1771051541


##########
tests/providers/google/cloud/sensors/test_pubsub.py:
##########
@@ -197,3 +198,53 @@ def test_pubsub_pull_sensor_async_execute_complete(self):
         with mock.patch.object(operator.log, "info") as mock_log_info:
             operator.execute_complete(context={}, event={"status": "success", 
"message": test_message})
         mock_log_info.assert_called_with("Sensor pulls messages: %s", 
test_message)
+
+    @mock.patch("airflow.providers.google.cloud.sensors.pubsub.PubSubHook")
+    def 
test_pubsub_pull_sensor_async_execute_complete_use_message_callback(self, 
mock_hook):
+        test_message = [
+            {
+                "ack_id": 
"UAYWLF1GSFE3GQhoUQ5PXiM_NSAoRRIJB08CKF15MU0sQVhwaFENGXJ9YHxrUxsDV0ECel1RGQdoTm11H4GglfRLQ1RrWBIHB01Vel5TEwxoX11wBnm4vPO6v8vgfwk9OpX-8tltO6ywsP9GZiM9XhJLLD5-LzlFQV5AEkwkDERJUytDCypYEU4EISE-MD5FU0Q",
+                "message": {
+                    "data": "aGkgZnJvbSBjbG91ZCBjb25zb2xlIQ==",
+                    "message_id": "12165864188103151",
+                    "publish_time": "2024-08-28T11:49:50.962Z",
+                    "attributes": {},
+                    "ordering_key": "",
+                },
+                "delivery_attempt": 0,
+            }
+        ]
+        received_message_format = []
+        for msg in test_message:
+            
received_message_format.append(pubsub_v1.types.ReceivedMessage(msg))
+
+        messages_callback_return_value = "custom_message_from_callback"
+
+        def messages_callback(
+            pulled_messages: list[ReceivedMessage],
+            context: dict[str, Any],
+        ):
+            assert pulled_messages == received_message_format
+
+            assert isinstance(context, dict)
+            for key in context.keys():
+                assert isinstance(key, str)
+
+            return messages_callback_return_value
+
+        messages_callback = mock.Mock(side_effect=messages_callback)

Review Comment:
   ah good catch, not required.



##########
tests/providers/google/cloud/sensors/test_pubsub.py:
##########
@@ -197,3 +198,53 @@ def test_pubsub_pull_sensor_async_execute_complete(self):
         with mock.patch.object(operator.log, "info") as mock_log_info:
             operator.execute_complete(context={}, event={"status": "success", 
"message": test_message})
         mock_log_info.assert_called_with("Sensor pulls messages: %s", 
test_message)
+
+    @mock.patch("airflow.providers.google.cloud.sensors.pubsub.PubSubHook")
+    def 
test_pubsub_pull_sensor_async_execute_complete_use_message_callback(self, 
mock_hook):
+        test_message = [
+            {
+                "ack_id": 
"UAYWLF1GSFE3GQhoUQ5PXiM_NSAoRRIJB08CKF15MU0sQVhwaFENGXJ9YHxrUxsDV0ECel1RGQdoTm11H4GglfRLQ1RrWBIHB01Vel5TEwxoX11wBnm4vPO6v8vgfwk9OpX-8tltO6ywsP9GZiM9XhJLLD5-LzlFQV5AEkwkDERJUytDCypYEU4EISE-MD5FU0Q",
+                "message": {
+                    "data": "aGkgZnJvbSBjbG91ZCBjb25zb2xlIQ==",
+                    "message_id": "12165864188103151",
+                    "publish_time": "2024-08-28T11:49:50.962Z",
+                    "attributes": {},
+                    "ordering_key": "",
+                },
+                "delivery_attempt": 0,
+            }
+        ]
+        received_message_format = []
+        for msg in test_message:
+            
received_message_format.append(pubsub_v1.types.ReceivedMessage(msg))

Review Comment:
   updated .



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