Skip to content

Commit 9b60777

Browse files
committed
small test fixes
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent b1ffeb0 commit 9b60777

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

polars_io_tools/io_sources/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ def _storage_options_for(cache_uri: str, aws_profile: str | None = None) -> Stor
163163
cred_opts = credential_provider._storage_update_options()
164164
endpoint = cred_opts.get("endpoint_url")
165165

166+
if endpoint:
167+
endpoint = _resolve_endpoint_hostname(endpoint)
168+
166169
# Set endpoint in both option dicts with appropriate keys
167170
if endpoint:
168171
pyarrow_opts["endpoint_override"] = endpoint

polars_io_tools/tests/io_sources/test_util.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ def test_resolve_hostname_with_port(self, monkeypatch):
10761076
"""Test resolving hostname to IP when endpoint has a port."""
10771077
monkeypatch.setattr("socket.gethostbyname", lambda hostname: "10.1.2.3")
10781078

1079-
result = _resolve_endpoint_hostname("http://:9020")
1079+
result = _resolve_endpoint_hostname("http://grid:9020")
10801080

10811081
assert result == "http://10.1.2.3:9020"
10821082

@@ -1108,7 +1108,7 @@ def test_resolve_hostname_with_path(self, monkeypatch):
11081108
"""Test that paths are preserved in the resolved URL."""
11091109
monkeypatch.setattr("socket.gethostbyname", lambda hostname: "10.1.2.3")
11101110

1111-
result = _resolve_endpoint_hostname("http://:9020/some/path")
1111+
result = _resolve_endpoint_hostname("http://grid:9020/some/path")
11121112

11131113
assert result == "http://10.1.2.3:9020/some/path"
11141114

@@ -1157,9 +1157,9 @@ def capture_gethostbyname(hostname):
11571157

11581158
monkeypatch.setattr("socket.gethostbyname", capture_gethostbyname)
11591159

1160-
_resolve_endpoint_hostname("http://:9020")
1160+
_resolve_endpoint_hostname("http://grid:9020")
11611161

1162-
assert captured_hostname["value"] == ""
1162+
assert captured_hostname["value"] == "grid"
11631163

11641164
def test_storage_options_resolution_failure_keeps_original(self, monkeypatch, caplog):
11651165
"""Test that DNS resolution failure in _storage_options_for keeps the original endpoint."""
@@ -1190,11 +1190,11 @@ def failing_gethostbyname(hostname):
11901190
monkeypatch.setattr("boto3.Session", FakeSession)
11911191
monkeypatch.setattr("polars_io_tools.io_sources.util.pl.CredentialProviderAWS", FakeCredentialProvider, raising=False)
11921192
monkeypatch.setattr("socket.gethostbyname", failing_gethostbyname)
1193-
monkeypatch.setenv("AWS_ENDPOINT_URL", "http://:9020")
1193+
monkeypatch.setenv("AWS_ENDPOINT_URL", "http://grid:9020")
11941194

11951195
opts = _storage_options_for("s3://bucket/path")
11961196

11971197
# Endpoint should be kept as original due to resolution failure
1198-
assert opts.pyarrow["endpoint_override"] == "http://:9020"
1199-
assert opts.polars["endpoint_url"] == "http://:9020"
1198+
assert opts.pyarrow["endpoint_override"] == "http://grid:9020"
1199+
assert opts.polars["endpoint_url"] == "http://grid:9020"
12001200
assert "Failed to resolve hostname" in caplog.text

0 commit comments

Comments
 (0)