jason810496 commented on code in PR #64612:
URL: https://github.com/apache/airflow/pull/64612#discussion_r3042608753


##########
providers/apache/kafka/tests/unit/apache/kafka/triggers/test_await_message.py:
##########
@@ -142,6 +145,40 @@ async def test_trigger_run_bad(self, mocker):
         assert task.done() is False
         asyncio.get_event_loop().stop()
 
+    @pytest.mark.asyncio
+    async def test_cleanup_closes_consumer(self, mocker):
+        consumer = MockedConsumer()
+        close_mock = mocker.patch.object(consumer, "close")
+
+        mocker.patch.object(KafkaConsumerHook, "get_consumer", 
return_value=consumer)
+
+        trigger = AwaitMessageTrigger(
+            kafka_config_id="kafka_d",
+            
apply_function="unit.apache.kafka.triggers.test_await_message.apply_function_true",
+            topics=["noop"],
+            poll_timeout=0.0001,
+            poll_interval=5,
+        )
+
+        generator = trigger.run()
+        await generator.__anext__()
+        await trigger.cleanup()
+        await generator.aclose()
+
+        close_mock.assert_called_once_with()
+
+    @pytest.mark.asyncio
+    async def test_cleanup_without_consumer_is_noop(self):

Review Comment:
   I renamed to `test_cleanup_does_not_raise_without_consumer` to clarify the 
purpose.



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