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 2020/06/18 13:59:20 UTC

[GitHub] [airflow] zikun commented on a change in pull request #9322: DAG Source endpoint

zikun commented on a change in pull request #9322:
URL: https://github.com/apache/airflow/pull/9322#discussion_r442247749



##########
File path: tests/api_connexion/endpoints/test_dag_source_endpoint.py
##########
@@ -40,7 +49,43 @@ def setUpClass(cls) -> None:
     def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
-    def test_should_response_200(self):
-        response = self.client.get("/api/v1/health")
-        assert response.status_code == 200
+    @parameterized.expand([("True",), ("False",)])
+    def test_should_response_200_text(self, store_serialized_dags):
+        serializer = URLSafeSerializer(conf.get('webserver', 'SECRET_KEY'))
+        with conf_vars(
+            {("core", "store_serialized_dags"): store_serialized_dags}
+        ):
+            dagbag = DagBag(dag_folder=EXAMPLE_DAG_FILE)
+            dagbag.sync_to_db()
+            first_dag: DAG = next(iter(dagbag.dags.values()))
+
+            url = f"/api/v1/dagSources/{serializer.dumps(first_dag.fileloc)}"
+            response = self.client.get(url, headers={
+                "Accept": "text/plain"
+            })
+
+            self.assertEqual(200, response.status_code)
+            self.assertIn("Example DAG demonstrating the usage of the BashOperator.", response.data.decode())
+            self.assertEqual('text/plain', response.headers['Content-Type'])
+
+    @parameterized.expand([("True",), ("False",)])
+    def test_should_response_200_json(self, store_serialized_dags):

Review comment:
       Shouldn't the test parameter be `store_dag_code` instead of `store_serialized_dags`?




----------------------------------------------------------------
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:
users@infra.apache.org