bugraoz93 commented on code in PR #42782:
URL: https://github.com/apache/airflow/pull/42782#discussion_r1794300765


##########
tests/api_fastapi/views/public/test_connections.py:
##########
@@ -102,3 +115,76 @@ def test_get_should_respond_200_with_extra_redacted(self, 
test_client, session):
         assert body["conn_id"] == TEST_CONN_ID
         assert body["conn_type"] == TEST_CONN_TYPE
         assert body["extra"] == '{"password": "***"}'
+
+
+class TestGetConnections(TestConnectionEndpoint):
+    def test_should_respond_200(self, test_client, session):
+        self.create_connections()
+        result = session.query(Connection).all()
+        assert len(result) == 2
+        response = test_client.get("/public/connections/")
+        assert response.status_code == 200
+        assert response.json() == {
+            "connections": [
+                {
+                    "conn_id": TEST_CONN_ID,
+                    "conn_type": TEST_CONN_TYPE,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+                {
+                    "conn_id": TEST_CONN_ID_2,
+                    "conn_type": TEST_CONN_TYPE_2,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+            ],
+            "total_entries": 2,
+        }
+
+    def test_should_respond_200_with_order_by(self, test_client, session):
+        self.create_connections()
+        result = session.query(Connection).all()
+        assert len(result) == 2
+        response = 
test_client.get("/public/connections/?order_by=-connection_id")
+        assert response.status_code == 200
+        # Using - means descending
+        assert response.json() == {
+            "connections": [
+                {
+                    "conn_id": TEST_CONN_ID_2,
+                    "conn_type": TEST_CONN_TYPE_2,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+                {
+                    "conn_id": TEST_CONN_ID,
+                    "conn_type": TEST_CONN_TYPE,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+            ],
+            "total_entries": 2,
+        }
+
+    # TODO: Re-enable when permissions are handled.
+    # def test_should_raises_401_unauthenticated(self, test_client):
+    # response = test_client.get("/public/connections")
+    #
+    # assert on response

Review Comment:
   Removed



##########
tests/api_fastapi/views/public/test_connections.py:
##########
@@ -102,3 +115,76 @@ def test_get_should_respond_200_with_extra_redacted(self, 
test_client, session):
         assert body["conn_id"] == TEST_CONN_ID
         assert body["conn_type"] == TEST_CONN_TYPE
         assert body["extra"] == '{"password": "***"}'
+
+
+class TestGetConnections(TestConnectionEndpoint):
+    def test_should_respond_200(self, test_client, session):
+        self.create_connections()
+        result = session.query(Connection).all()
+        assert len(result) == 2
+        response = test_client.get("/public/connections/")
+        assert response.status_code == 200
+        assert response.json() == {
+            "connections": [
+                {
+                    "conn_id": TEST_CONN_ID,
+                    "conn_type": TEST_CONN_TYPE,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+                {
+                    "conn_id": TEST_CONN_ID_2,
+                    "conn_type": TEST_CONN_TYPE_2,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+            ],
+            "total_entries": 2,
+        }
+
+    def test_should_respond_200_with_order_by(self, test_client, session):
+        self.create_connections()
+        result = session.query(Connection).all()
+        assert len(result) == 2
+        response = 
test_client.get("/public/connections/?order_by=-connection_id")
+        assert response.status_code == 200
+        # Using - means descending
+        assert response.json() == {
+            "connections": [
+                {
+                    "conn_id": TEST_CONN_ID_2,
+                    "conn_type": TEST_CONN_TYPE_2,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+                {
+                    "conn_id": TEST_CONN_ID,
+                    "conn_type": TEST_CONN_TYPE,
+                    "description": None,
+                    "extra": None,
+                    "host": None,
+                    "login": None,
+                    "schema": None,
+                    "port": None,
+                },
+            ],
+            "total_entries": 2,
+        }
+
+    # TODO: Re-enable when permissions are handled.
+    # def test_should_raises_401_unauthenticated(self, test_client):
+    # response = test_client.get("/public/connections")
+    #
+    # assert on response

Review Comment:
   Removed :+1: 



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to