You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/05/29 15:06:30 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #9058: Improve test for the next_execution cli command

turbaszek commented on a change in pull request #9058:
URL: https://github.com/apache/airflow/pull/9058#discussion_r432549412



##########
File path: tests/cli/commands/test_dag_command.py
##########
@@ -240,21 +239,30 @@ def test_cli_backfill_depends_on_past_backwards(self, mock_run):
 
     @pytest.mark.quarantined
     def test_next_execution(self):
-        # A scaffolding function
-        def reset_dr_db(dag_id):
-            session = Session()
-            dr = session.query(DagRun).filter_by(dag_id=dag_id)
-            dr.delete()
-            session.commit()
-            session.close()
-
         dag_ids = ['example_bash_operator',  # schedule_interval is '0 0 * * *'
                    'latest_only',  # schedule_interval is timedelta(hours=4)
                    'example_python_operator',  # schedule_interval=None
                    'example_xcom']  # schedule_interval="@once"
 
+        session = Session()
+        dr = session.query(DagRun).filter(DagRun.dag_id.in_(dag_ids))
+        dr.delete(synchronize_session=False)
+        session.commit()
+        session.close()

Review comment:
       Let's use `create_session` context manager, WDYT?




----------------------------------------------------------------
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:
users@infra.apache.org