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/13 07:16:37 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9266: [WIP]add crud endpoint for connections

ephraimbuddy commented on a change in pull request #9266:
URL: https://github.com/apache/airflow/pull/9266#discussion_r439717022



##########
File path: tests/api_connexion/endpoints/test_connection_endpoint.py
##########
@@ -207,7 +230,32 @@ def test_should_response_200(self):
 
 
 class TestPostConnection(TestConnectionEndpoint):
-    @unittest.skip("Not implemented yet")
-    def test_should_response_200(self):
-        response = self.client.post("/api/v1/connections/")
+
+    @provide_session
+    def test_post_should_response_200(self, session):
+        payload = {
+            "connection_id": "test-connection-id",
+            "conn_type": 'test_type'
+        }
+        response = self.client.post("/api/v1/connections", json=payload)
         assert response.status_code == 200
+        connection = session.query(Connection).all()
+        assert len(connection) == 1
+        self.assertEqual(connection[0].conn_id, 'test-connection-id')
+
+    def test_post_should_response_400_for_invalid_payload(self):
+        payload = {
+            "connection_id": "test-connection-id",
+        }  # conn_type missing
+        response = self.client.post("/api/v1/connections", json=payload)
+        assert response.status_code == 400
+        self.assertEqual(response.json,
+                         {'detail': "'conn_type' is a required property",
+                          'status': 400,
+                          'title': 'Bad Request',
+                          'type': 'about:blank'}
+                         )
+
+    @unittest.skip('not implemented yet')
+    def test_delete_should_response_409_already_exist(self):

Review comment:
       ```suggestion
       def test_post_should_response_409_already_exist(self):
   ```




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