mik-laj commented on a change in pull request #9266:
URL: https://github.com/apache/airflow/pull/9266#discussion_r443196939



##########
File path: tests/api_connexion/endpoints/test_connection_endpoint.py
##########
@@ -200,14 +229,215 @@ def _create_connections(self, count):
 
 
 class TestPatchConnection(TestConnectionEndpoint):
-    @unittest.skip("Not implemented yet")
-    def test_should_response_200(self):
-        response = self.client.patch("/api/v1/connections/1")
+
+    @provide_session
+    def test_patch_should_response_200(self, session):
+        self._create_connection(session)
+        payload = {
+            "connection_id": "test-connection-id",
+            "conn_type": 'test_type',
+            "extra": "{'key': 'var'}"
+        }
+        response = self.client.patch("/api/v1/connections/test-connection-id",
+                                     json=payload)
+        assert response.status_code == 200
+
+    @provide_session
+    def test_patch_should_response_200_with_update_mask(self, session):
+        self._create_connection(session)
+        test_connection = "test-connection-id"
+        payload = {
+            "connection_id": test_connection,
+            "conn_type": 'test_type_2',
+            "extra": "{'key': 'var'}",
+            'login': "login",
+            "port": 80,
+        }
+        response = self.client.patch(
+            "/api/v1/connections/test-connection-id?update_mask=port,login",
+            json=payload
+        )
         assert response.status_code == 200
+        connection = 
session.query(Connection).filter_by(conn_id=test_connection).first()
+        self.assertEqual(connection.password, None)
+        self.assertEqual(
+            response.json,
+            {
+                "connection_id": test_connection,  # not updated
+                "conn_type": 'test_type',  # Not updated
+                "extra": None,  # Not updated
+                'login': "login",  # updated
+                "port": 80,  # updated
+                "schema": None,
+                "host": None
+
+            }
+        )
+
+    @parameterized.expand(
+        [
+            (
+                {
+                    "connection_id": 'test-connection-id',

Review comment:
       Can you add a test that checks the request without the connection_id key?




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