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


##########
tests/executors/test_kubernetes_executor.py:
##########
@@ -1162,6 +1166,39 @@ def test_supports_pickling(self):
     def test_supports_sentry(self):
         assert not KubernetesExecutor.supports_sentry
 
+    def test_annotations_for_logging_task_metadata(self):
+        annotations_test = {
+            "dag_id": "dag",
+            "run_id": "run_id",
+            "task_id": "task",
+            "try_number": "1",
+        }
+        with mock.patch.dict(
+            os.environ, {"AIRFLOW__KUBERNETES_EXECUTOR__LOGS_TASK_METADATA": 
"True"}, clear=True
+        ):
+            expected_annotations = {
+                "dag_id": "dag",
+                "run_id": "run_id",
+                "task_id": "task",
+                "try_number": "1",
+            }
+            annotations_actual = 
annotations_for_logging_task_metadata(annotations_test)
+            assert annotations_actual == expected_annotations
+
+    def test_annotations_for_logging_task_metadata_fallback(self):
+        annotations_test = {
+            "dag_id": "dag",
+            "run_id": "run_id",
+            "task_id": "task",
+            "try_number": "1",
+        }
+        with mock.patch.dict(
+            os.environ, {"AIRFLOW__KUBERNETES_EXECUTOR__LOGS_TASK_METADATA": 
"False"}, clear=True
+        ):
+            expected_annotations = "<omitted>"
+            annotations_actual = 
annotations_for_logging_task_metadata(annotations_test)
+            assert annotations_actual == expected_annotations
+

Review Comment:
   @uranusjr I didn't quite get what you meant by `You also want to patch both 
the true and false cases because it’s not deterministic in the CI which the 
config is set to when the test is run.`
   
   I have patched both the test cases, True on line 1177 and False on line 1196



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