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 2021/07/30 07:21:16 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #17324: Improve `dag_maker` fixture

ephraimbuddy commented on a change in pull request #17324:
URL: https://github.com/apache/airflow/pull/17324#discussion_r679708043



##########
File path: tests/conftest.py
##########
@@ -444,33 +445,44 @@ def __exit__(self, type, value, traceback):
             dag.__exit__(type, value, traceback)
             if type is None:
                 dag.clear()
-                self.dag_run = dag.create_dagrun(
-                    run_id=self.kwargs.get("run_id", "test"),
-                    state=self.kwargs.get('state', State.RUNNING),
-                    execution_date=self.kwargs.get('execution_date', self.kwargs['start_date']),
-                    start_date=self.kwargs['start_date'],
-                )
+
+        def _set_default_args(self, kwargs, defaults):
+            for k, v in defaults.items():
+                if k not in kwargs:
+                    kwargs.setdefault(k, v)
+
+        @provide_session
+        def make_dagmodel(self, session=None, **kwargs):
+            dag = self.dag
+            defaults = dict(dag_id=dag.dag_id, next_dagrun=dag.start_date, is_active=True)
+            self._set_default_args(kwargs, defaults)

Review comment:
       This is so apt! Thanks!




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org