psg2 commented on a change in pull request #16842:
URL: https://github.com/apache/airflow/pull/16842#discussion_r664983577



##########
File path: tests/api_connexion/endpoints/test_dag_endpoint.py
##########
@@ -137,54 +155,44 @@ def _create_deactivated_dag(self, session=None):
 
 
 class TestGetDag(TestDagEndpoint):
-    @conf_vars({("webserver", "secret_key"): "mysecret"})
     def test_should_respond_200(self):
-        self._create_dag_models(1)
-        response = self.client.get("/api/v1/dags/TEST_DAG_1", 
environ_overrides={'REMOTE_USER': "test"})
+        response = self.client.get(f"/api/v1/dags/{self.dag_id}", 
environ_overrides={'REMOTE_USER': "test"})
         assert response.status_code == 200
         assert {
-            "dag_id": "TEST_DAG_1",
+            "dag_id": self.dag_id,
             "description": None,
-            "fileloc": "/tmp/dag_1.py",
-            "file_token": 'Ii90bXAvZGFnXzEucHki.EnmIdPaUPo26lHQClbWMbDFD1Pk',
-            "is_paused": False,
-            "is_active": True,
+            "fileloc": __file__,
+            "file_token": FILE_TOKEN,
+            "is_paused": None,

Review comment:
       I did remove those after changing the endpoint to return a DAG instead 
of a DagModel given that the API documentation says that the `is_active` field 
is nullable.
   
   
![image](https://user-images.githubusercontent.com/14082115/124688221-cbcec900-deac-11eb-80b1-f6c91475c552.png)
   
   To fix this, should I transform from DAG to DagModel and leave the 
serializer to handle it, or take the approach from the DAGDetailSchema that has 
the following code:
   
   ```py
       is_paused = fields.Method("get_is_paused", dump_only=True)
       is_active = fields.Method("get_is_active", dump_only=True)
   
       @staticmethod
       def get_is_paused(obj: DAG):
           """Checks entry in DAG table to see if this DAG is paused"""
           return obj.get_is_paused()
   
       @staticmethod
       def get_is_active(obj: DAG):
           """Checks entry in DAG table to see if this DAG is active"""
           return obj.get_is_active()
   ```
   




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