Vamsi-klu commented on code in PR #73070:
URL: https://github.com/apache/airflow/pull/73070#discussion_r4002488696
##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -316,6 +316,35 @@ def test_next_execution_table_flag_with_no_next_run(
clear_db_dags()
self.setup_class()
+ @conf_vars({("core", "load_examples"): "false"})
+ @pytest.mark.parametrize("field", ["data_interval.start",
"data_interval.end"])
+ def test_next_execution_data_interval_field_on_partitioned_dag(self,
field, tmp_path, stdout_capture):
+ dag_id = "partitioned_data_interval_field"
+ file_content = os.linesep.join(
+ [
+ "from airflow import DAG",
+ "from airflow.providers.standard.operators.empty import
EmptyOperator",
+ "from airflow.timetables.trigger import
CronPartitionTimetable",
+ "from datetime import timedelta; from pendulum import today",
+ f"dag = DAG('{dag_id}', start_date=today(tz='UTC') +
timedelta(days=-5),"
+ " schedule=CronPartitionTimetable('0 0 * * *',
timezone='UTC'), catchup=False)",
+ "task = EmptyOperator(task_id='empty_task', dag=dag)",
+ ]
+ )
+ (tmp_path / f"{dag_id}.py").write_text(file_content)
+ with time_machine.travel(DEFAULT_DATE):
+ clear_db_dags()
+ parse_and_sync_to_db(tmp_path)
+
+ args = self.parser.parse_args(["dags", "next-execution", dag_id,
"--field", field])
+ with stdout_capture as temp_stdout:
+ dag_command.dag_next_execution(args)
+ out = temp_stdout.getvalue()
+ assert out.splitlines() == ["None"]
+
+ clear_db_dags()
+ self.setup_class()
+
Review Comment:
assert out.splitlines() == ["None"] is also what you get when there is no
next run (the command prints None on stdout and the warn on stderr). This test
never checks stderr. Today the sibling setup produces a run. If that stops, the
test stays green and no longer covers the crash.
Assert stderr is empty so None is the field, not a missing schedule. Also
worth one case where data_interval.start is actually populated.
--
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]