shashbha14 commented on code in PR #66102:
URL: https://github.com/apache/airflow/pull/66102#discussion_r3190543617


##########
task-sdk/tests/task_sdk/definitions/test_timetables.py:
##########
@@ -18,26 +18,29 @@
 
 import pytest
 
-from airflow.sdk.exceptions import NodeNotFound, TaskNotFound
+from airflow.sdk.definitions.timetables._cron import CRON_PRESETS, CronMixin
+from airflow.sdk.exceptions import AirflowTimetableInvalid
 
+SAMPLE_TZ = "UTC"
 
-def test_node_not_found_is_subclass_of_task_not_found():
-    assert issubclass(NodeNotFound, TaskNotFound)
 
[email protected](("preset", "expected"), CRON_PRESETS.items())
+def test_cron_preset_resolved(preset, expected):
+    cm = CronMixin(expression=preset, timezone=SAMPLE_TZ)
+    assert cm.expression == expected
 
-def test_node_not_found_is_subclass_of_key_error():
-    assert issubclass(NodeNotFound, KeyError)
 
+def test_cron_preset_validate_does_not_raise():
+    cm = CronMixin(expression="@quarterly", timezone=SAMPLE_TZ)
+    cm.validate()  # should not raise
 
-def test_node_not_found_caught_as_key_error():
-    with pytest.raises(KeyError):
-        raise NodeNotFound("missing_task")
 
+def test_invalid_cron_expression_raises():
+    cm = CronMixin(expression="invalid", timezone=SAMPLE_TZ)
+    with pytest.raises(AirflowTimetableInvalid):
+        cm.validate()
 
-def test_node_not_found_caught_as_task_not_found():
-    with pytest.raises(TaskNotFound):
-        raise NodeNotFound("missing_task")
 
-
-def test_node_not_found_str_suppresses_key_error_repr():
-    assert str(NodeNotFound("missing")) == "missing"
+def test_valid_cron_expression_does_not_raise():
+    cm = CronMixin(expression="0 0 * * *", timezone=SAMPLE_TZ)
+    cm.validate()

Review Comment:
   Added test_cron_data_interval_timetable_quarterly_preset which uses 
CronDataIntervalTimetable directly, matching the real-world entry point from 
#66101.



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