ashb commented on code in PR #45094:
URL: https://github.com/apache/airflow/pull/45094#discussion_r1893172106


##########
tests/dag_processing/test_collection.py:
##########
@@ -414,3 +420,68 @@ def _sync_perms():
         spy_agency.assert_spy_called_with(
             spy, dag.dag_id, access_control={"Public": {"DAGs": {"can_read"}, 
"DAG Runs": {"can_create"}}}
         )
+
+    @pytest.mark.parametrize(
+        ("attrs", "expected"),
+        [
+            pytest.param(
+                {
+                    "_tasks_": [
+                        EmptyOperator(task_id="task", owner="owner1"),
+                        EmptyOperator(task_id="task2", owner="owner2"),
+                        EmptyOperator(task_id="task3"),
+                        EmptyOperator(task_id="task4", owner="owner2"),
+                    ]
+                },
+                {
+                    "default_view": conf.get("webserver", 
"dag_default_view").lower(),
+                    "owners": ["owner1", "owner2"],
+                },
+                id="tasks-multiple-owners",
+            ),
+            pytest.param(
+                {"is_paused_upon_creation": True},
+                {"is_paused": True},
+                id="is_paused_upon_creation",
+            ),
+            pytest.param(
+                {},
+                {"owners": ["airflow"]},
+                id="default-owner",
+            ),
+        ],
+    )
+    @pytest.mark.usefixtures("clean_db")
+    def test_dagmodel_properties(self, attrs, expected, session, time_machine):
+        """Test that properties on the dag model are correctly set when 
dealing with a LazySerializedDag"""
+        dt = tz.datetime(2020, 1, 5, 0, 0, 0)
+        time_machine.move_to(dt, tick=False)
+
+        tasks = attrs.pop("_tasks_", None)
+        dag = DAG("dag", **attrs)
+        if tasks:
+            dag.add_tasks(tasks)
+
+        update_dag_parsing_results_in_db([self.dag_to_lazy_serdag(dag)], {}, 
None, set(), session)
+
+        orm_dag = session.get(DagModel, ("dag",))
+
+        for attrname, expected_value in expected.items():
+            if attrname == "owners":
+                assert sorted(orm_dag.owners.split(", ")) == expected_value
+            else:
+                assert getattr(orm_dag, attrname) == expected_value
+
+        assert orm_dag.last_parsed_time == dt
+
+    def test_existing_dag_is_paused_upon_creation(self, session):
+        dag = DAG("dag_paused", schedule=None)
+        update_dag_parsing_results_in_db([self.dag_to_lazy_serdag(dag)], {}, 
None, set(), session)
+        orm_dag = session.get(DagModel, ("dag_paused",))
+        assert orm_dag.is_paused is False
+
+        dag = DAG("dag_paused", schedule=None, is_paused_upon_creation=True)
+        update_dag_parsing_results_in_db([self.dag_to_lazy_serdag(dag)], {}, 
None, set(), session)

Review Comment:
   ```suggestion
           update_dag_parsing_results_in_db([self.dag_to_lazy_serdag(dag)], {}, 
set(), session)
   ```
   



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