Skip to content

Commit bc85ee3

Browse files
committed
Address PR feedback: health catches non-API errors; isort imports; packaging version test; sandbox and transport tests.
1 parent b34203a commit bc85ee3

6 files changed

Lines changed: 42 additions & 6 deletions

File tree

hotdata_runtime/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from importlib.metadata import PackageNotFoundError, version
44

55
from hotdata_runtime.client import HotdataClient, from_env
6-
from hotdata_runtime.health import workspace_health_lines
76
from hotdata_runtime.env import (
87
default_api_key,
98
default_host,
@@ -13,6 +12,7 @@
1312
normalize_host,
1413
pick_workspace,
1514
)
15+
from hotdata_runtime.health import workspace_health_lines
1616
from hotdata_runtime.result import QueryResult
1717

1818
try:

hotdata_runtime/health.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ def workspace_health_lines(client: HotdataClient) -> tuple[bool, list[str]]:
2323
return True, lines
2424
except ApiException as e:
2525
return False, [e.reason or str(e)]
26+
except Exception as e:
27+
return False, [str(e)]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616

1717
[dependency-groups]
1818
dev = [
19+
"packaging>=23",
1920
"pytest>=8.0",
2021
]
2122

tests/test_health.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ def list_connections(self):
2222
assert any("reachable" in p for p in parts)
2323

2424

25+
def test_workspace_health_ok_includes_sandbox_when_session_set():
26+
client = HotdataClient(
27+
"k", "ws", host="https://api.hotdata.dev", session_id="sb_test"
28+
)
29+
listing = type("L", (), {"connections": [object()]})()
30+
31+
class FakeConnectionsApi:
32+
def list_connections(self):
33+
return listing
34+
35+
with patch.object(client, "connections", return_value=FakeConnectionsApi()):
36+
ok, parts = workspace_health_lines(client)
37+
assert ok is True
38+
assert any("sandbox" in p and "sb_test" in p for p in parts)
39+
40+
2541
def test_workspace_health_api_error():
2642
client = HotdataClient("k", "ws", host="https://api.hotdata.dev")
2743

@@ -33,3 +49,16 @@ def list_connections(self):
3349
ok, parts = workspace_health_lines(client)
3450
assert ok is False
3551
assert parts == ["nope"]
52+
53+
54+
def test_workspace_health_non_api_error():
55+
client = HotdataClient("k", "ws", host="https://api.hotdata.dev")
56+
57+
class Boom:
58+
def list_connections(self):
59+
raise OSError("connection refused")
60+
61+
with patch.object(client, "connections", return_value=Boom()):
62+
ok, parts = workspace_health_lines(client)
63+
assert ok is False
64+
assert parts == ["connection refused"]

tests/test_version.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import re
2-
31
from importlib.metadata import version as dist_version
42

3+
from packaging.version import Version
4+
55
import hotdata_runtime as hr
66

77

8-
def test_version_is_pep440_core():
9-
assert re.fullmatch(r"\d+\.\d+\.\d+(\+.*)?", hr.__version__)
8+
def test_version_is_valid_pep440():
9+
Version(hr.__version__)
1010

1111

1212
def test_version_matches_distribution_metadata():

uv.lock

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)