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



##########
File path: tests/api_connexion/endpoints/test_dag_endpoint.py
##########
@@ -58,13 +60,41 @@ def setUp(self) -> None:
     def tearDown(self) -> None:
         self.clean_db()
 
+    @provide_session
+    def _create_dag_models(self, count, session=None):
+        for num in range(1, count + 1):
+            dag_model = DagModel(
+                dag_id=f"TEST_DAG_{num}",
+                fileloc=f"/tmp/dag_{num}.py",
+                schedule_interval="2 2 * * *"
+            )
+            session.add(dag_model)
+
 
 class TestGetDag(TestDagEndpoint):
-    @pytest.mark.skip(reason="Not implemented yet")
     def test_should_response_200(self):
-        response = self.client.get("/api/v1/dags/1/")
+        self._create_dag_models(1)
+        response = self.client.get("/api/v1/dags/TEST_DAG_1")
         assert response.status_code == 200
 
+        current_response = response.json
+        current_response["fileloc"] = "/tmp/test-dag.py"
+        self.assertEqual({
+            'dag_id': 'TEST_DAG_1',
+            'description': None,
+            'fileloc': '/tmp/test-dag.py',
+            'is_paused': False,
+            'is_subdag': False,
+            'owners': [],
+            'root_dag_id': None,
+            'schedule_interval': {'__type': 'CronExpression', 'value': '2 2 * 
* *'},
+            'tags': []
+        }, current_response)
+
+    def test_should_response_404(self):
+        response = self.client.get("/api/v1/dags/INVALID_DAG/")

Review comment:
       ```suggestion
           response = self.client.get("/api/v1/dags/INVALID_DAG")
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to