You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ephraimbuddy (via GitHub)" <gi...@apache.org> on 2023/02/01 07:03:15 UTC

[GitHub] [airflow] ephraimbuddy commented on a diff in pull request #29224: add output format arg for `cli.dags.trigger`

ephraimbuddy commented on code in PR #29224:
URL: https://github.com/apache/airflow/pull/29224#discussion_r1092826281


##########
tests/api/client/test_local_client.py:
##########
@@ -128,6 +128,45 @@ def test_trigger_dag(self, mock):
             )
             mock.reset_mock()
 
+            # test output
+            queued_at = pendulum.now()
+            started_at = pendulum.now()
+            mock.return_value = DagRun(
+                dag_id=test_dag_id,
+                run_id=run_id,
+                queued_at=queued_at,
+                execution_date=EXECDATE,
+                start_date=started_at,
+                external_trigger=True,
+                state=DagRunState.QUEUED,
+                conf={},
+                run_type=DagRunType.MANUAL,
+                data_interval=(EXECDATE, EXECDATE + pendulum.duration(hours=1)),
+            )
+            expected_dag_run = {
+                "conf": {},
+                "dag_id": test_dag_id,
+                "dag_run_id": run_id,
+                "data_interval_end": EXECDATE,
+                "data_interval_start": EXECDATE + pendulum.duration(hours=1),
+                "end_date": None,
+                "external_trigger": True,
+                "last_scheduling_decision": None,
+                "logical_date": EXECDATE,
+                "run_type": DagRunType.MANUAL,
+                "start_date": started_at,
+                "state": DagRunState.QUEUED,
+            }
+            dag_run = self.client.trigger_dag(dag_id=test_dag_id)
+            assert expected_dag_run == dag_run
+            mock.reset_mock()
+
+            # test output when no DagRun is created
+            mock.return_value = None
+            dag_run = self.client.trigger_dag(dag_id=test_dag_id)
+            assert None is dag_run

Review Comment:
   ```suggestion
               assert not dag_run
   ```



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