yuqian90 commented on a change in pull request #7038: [AIRFLOW-4495] allow externally triggered dags to run for future exec dates URL: https://github.com/apache/airflow/pull/7038#discussion_r368393431
########## File path: tests/ti_deps/deps/test_runnable_exec_date_dep.py ########## @@ -39,11 +41,56 @@ def test_exec_date_after_end_date(self): """ If the dag's execution date is in the future this dep should fail """ - ti = self._get_task_instance( - dag_end_date=datetime(2016, 1, 3), - task_end_date=datetime(2016, 1, 3), - execution_date=datetime(2016, 1, 2), - ) + dag = DAG( + 'test_localtaskjob_heartbeat', + start_date=datetime(2015, 1, 1), + end_date=datetime(2016, 11, 5), + schedule_interval=None) + + with dag: + op1 = DummyOperator(task_id='op1') + + ti = TaskInstance(task=op1, execution_date=datetime(2016, 11, 2)) + self.assertFalse(RunnableExecDateDep().is_met(ti=ti)) + + @conf_vars({ + ('scheduler', 'allow_trigger_in_future'): 'True' + }) + @freeze_time('2016-01-01') + def test_exec_date_after_end_date_with_allow_config(self): Review comment: @tooptoop4 you may consider replacing both `test_exec_date_after_end_date_with_allow_config_but_sched ` and `test_exec_date_after_end_date_with_allow_config ` with something like this. It's just a free function, does not have to be part of `class TestRunnableExecDateDep`. ```python import pytest @freeze_time('2016-11-01') @pytest.mark.parametrize("allow_trigger_in_future,schedule_interval,execution_date,is_met", [ ('True', None, datetime(2016, 11, 3), True), ('True', "@daily", datetime(2016, 11, 3), False), ('False', None, datetime(2016, 11, 3), False), ('False', "@daily", datetime(2016, 11, 3), False), ('False', "@daily", datetime(2016, 11, 1), True), ('False', None, datetime(2016, 11, 1), True)] ) def test_exec_date_dep(allow_trigger_in_future, schedule_interval, execution_date, is_met): """ If the dag's execution date is in the future this dep should fail """ with conf_vars({('scheduler', 'allow_trigger_in_future'): allow_trigger_in_future}): dag = DAG( 'test_localtaskjob_heartbeat', start_date=datetime(2015, 1, 1), end_date=datetime(2016, 11, 5), schedule_interval=schedule_interval) with dag: op1 = DummyOperator(task_id='op1') ti = TaskInstance(task=op1, execution_date=execution_date) assert RunnableExecDateDep().is_met(ti=ti) == is_met ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services