Revanth14 commented on code in PR #68700:
URL: https://github.com/apache/airflow/pull/68700#discussion_r3439393999


##########
airflow-core/tests/unit/models/test_connection.py:
##########
@@ -221,6 +223,57 @@ def test_parse_from_uri(
             assert conn.schema == expected_schema
             assert conn.extra_dejson == expected_extra_dict
 
+    @pytest.mark.parametrize(
+        ("port", "expected_port"),
+        [
+            (None, None),
+            (1, 1),
+            ("1", 1),
+            (65535, 65535),
+            ("65535", 65535),
+        ],
+    )
+    def test_connection_accepts_valid_ports(self, port, expected_port):
+        connection = Connection(conn_id="test_conn", conn_type="test", 
port=port)
+
+        assert connection.port == expected_port
+
+    @pytest.mark.parametrize("port", [-1, 0, 65536, "0", "65536", 
"not-a-port", True])
+    def test_connection_rejects_invalid_ports(self, port):
+        with pytest.raises(ValueError, match="port"):
+            Connection(conn_id="test_conn", conn_type="test", port=port)
+
+    def test_parse_from_uri_rejects_port_zero(self):
+        with pytest.raises(ValueError, match="between 1 and 65535"):
+            Connection(conn_id="test_conn", uri="type://host:0/schema")
+

Review Comment:
   Removed, thanks.



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