rawwar commented on code in PR #53477:
URL: https://github.com/apache/airflow/pull/53477#discussion_r2454707995
##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_pod.py:
##########
@@ -454,6 +454,53 @@ def test_find_custom_pod_labels(self):
assert "foo=bar" in label_selector
assert "hello=airflow" in label_selector
+ def test_build_find_pod_label_selector(self):
+ """Comprehensive single test combining all label normalization
scenarios.
+
+ Includes: normal labels, None values, empty string, zero, False.
+ Asserts: None -> empty assignment, other falsy preserved, core airflow
labels present, no literal 'None'.
+ """
+ k = KubernetesPodOperator(
+ labels={
+ "foo": "bar",
+ "hello": "airflow",
+ "a": None,
+ "b": "value",
+ "c": None,
+ "empty_str": "",
+ "zero": 0,
+ "false": False,
+ "none": None,
+ },
+ name="test",
+ task_id="task",
+ )
+ context = create_context(k)
+ label_selector = k._build_find_pod_label_selector(context)
+
+ # Standard labels
+ assert "foo=bar" in label_selector
+ assert "hello=airflow" in label_selector
+
+ # None normalization (shows as key= with no value)
+ for key in ["a", "c", "none"]:
+ assert f"{key}=" in label_selector
+
+ # Falsy but non-None values preserved verbatim
+ assert "empty_str=" in label_selector
+ assert "zero=0" in label_selector
+ assert "false=False" in label_selector
+
+ # Regular non-empty value
+ assert "b=value" in label_selector
Review Comment:
Do we need this as we are already have foo=bar or hello=airflow?
--
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]