Shrividya commented on code in PR #67719:
URL: https://github.com/apache/airflow/pull/67719#discussion_r3328062457


##########
airflow-core/tests/unit/jobs/test_triggerer_job.py:
##########
@@ -1051,6 +1051,48 @@ async def asend_side_effect(msg):
         assert len(first_call.events) == 3
         assert len(second_call.events) == 2
 
+    @pytest.mark.parametrize(
+        "payload",
+        [
+            pytest.param(
+                {"event": "hello"},
+                id="missing-level-key",
+            ),
+            pytest.param(
+                {"event": "hello", "level": "bogus_unknown_level"},
+                id="unknown-level-value",
+            ),
+        ],
+    )
+    def test_process_log_messages_tolerates_bad_level(self, payload):
+        """Log events with missing or unknown 'level' must not raise 
KeyError."""
+        import json
+
+        trigger_runner = TriggerRunner()
+        gen = trigger_runner._process_log_messages_from_subprocess()
+        next(gen)  # advance to yield
+
+        # Must not raise KeyError (the bug this test guards against)
+        gen.send(json.dumps(payload).encode())
+
+    def test_process_log_messages_valid_event_processed(self):
+        """Log events with a valid 'level' key are passed to the logger."""
+        import json
+        from unittest.mock import patch
+
+        trigger_runner = TriggerRunner()
+        mock_log = MagicMock()

Review Comment:
   seems like the import is missing here.



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