Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_conn(self) -> WeaviateClient:
grpc_secure = extras.pop("grpc_secure", False)
return weaviate.connect_to_custom(
http_host=conn.host, # type: ignore[arg-type]
http_port=conn.port or 443 if http_secure else 80,
http_port=conn.port or (443 if http_secure else 80),
http_secure=http_secure,
grpc_host=extras.pop("grpc_host", conn.host),
grpc_port=extras.pop("grpc_port", 443 if grpc_secure else 80),
Expand Down
10 changes: 5 additions & 5 deletions providers/weaviate/tests/unit/weaviate/hooks/test_weaviate.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix. wondering if it would be better to have one parameterized test case to specifically test for this port configuration. For example,

if port is not specified and http_secure is False, then 80
if port is not specified and http_secure is True, then 443
if port is set to 8000 and http_secure is False, then 8000
etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I think that it would, but I must admit that I am not that good with testing frameworks so I have not risked including it at the moment.

Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_get_conn_with_api_key_in_extra(self, mock_connect_to_custom, mock_auth_
mock_auth_api_key.assert_called_once_with(api_key=self.api_key)
mock_connect_to_custom.assert_called_once_with(
http_host=self.host,
http_port=80,
http_port=8000,
http_secure=False,
grpc_host="localhost",
grpc_port=50051,
Expand All @@ -198,7 +198,7 @@ def test_get_conn_with_token_in_extra(self, mock_connect_to_custom, mock_auth_ap
mock_auth_api_key.assert_called_once_with(api_key=self.api_key)
mock_connect_to_custom.assert_called_once_with(
http_host=self.host,
http_port=80,
http_port=8000,
http_secure=False,
grpc_host="localhost",
grpc_port=50051,
Expand All @@ -216,7 +216,7 @@ def test_get_conn_with_access_token_in_extra(self, mock_connect_to_custom, mock_
)
mock_connect_to_custom.assert_called_once_with(
http_host=self.host,
http_port=80,
http_port=8000,
http_secure=False,
grpc_host="localhost",
grpc_port=50051,
Expand All @@ -236,7 +236,7 @@ def test_get_conn_with_client_secret_in_extra(self, mock_connect_to_custom, mock
)
mock_connect_to_custom.assert_called_once_with(
http_host=self.host,
http_port=80,
http_port=8000,
http_secure=False,
grpc_host="localhost",
grpc_port=50051,
Expand All @@ -252,7 +252,7 @@ def test_get_conn_with_client_password_in_extra(self, mock_connect_to_custom, mo
mock_auth_client_password.assert_called_once_with(username="login", password="password", scope=None)
mock_connect_to_custom.assert_called_once_with(
http_host=self.host,
http_port=80,
http_port=8000,
http_secure=False,
grpc_host="localhost",
grpc_port=50051,
Expand Down