Skip to content
Merged
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "drukbox-python-sdk"
version = "0.4.0"
version = "0.5.0"
description = "Async Python client for Drukbox."
readme = "README.md"
license = "MIT"
Expand Down
6 changes: 4 additions & 2 deletions src/drukbox_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ class DoctorReport:

ok: bool
active_provider: str
tailscale_enabled: bool
# Whether the active provider's hosts join the tailnet.
tailnet: bool
checks: list[DoctorCheck]


Expand Down Expand Up @@ -490,7 +491,8 @@ async def doctor(self) -> DoctorReport:
return DoctorReport(
ok=data["ok"],
active_provider=data["active_provider"],
tailscale_enabled=data["tailscale_enabled"],
# drukbox before "Join the tailnet per provider" sent tailscale_enabled.
tailnet=data["tailnet"] if "tailnet" in data else data["tailscale_enabled"],
checks=[DoctorCheck(**check) for check in data["checks"]],
)

Expand Down
15 changes: 13 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _doctor_payload(**overrides: Any) -> dict[str, Any]:
payload: dict[str, Any] = {
"ok": True,
"active_provider": "aws",
"tailscale_enabled": True,
"tailnet": True,
"checks": [
{
"name": "db",
Expand Down Expand Up @@ -925,6 +925,17 @@ def test_from_env_strips_trailing_slash_via_constructor(
assert sandbox.base_url == "https://trailing.test"


@respx.mock
async def test_doctor_reads_tailscale_enabled_from_an_older_drukbox(api: SandboxAPI):
payload = _doctor_payload()
payload["tailscale_enabled"] = payload.pop("tailnet")
respx.get(f"{BASE_URL}/doctor").mock(return_value=httpx.Response(200, json=payload))

report = await api.doctor()

assert report.tailnet is True


@respx.mock
async def test_doctor_parses_report_and_checks(api: SandboxAPI):
route = respx.get(f"{BASE_URL}/doctor").mock(
Expand All @@ -937,7 +948,7 @@ async def test_doctor_parses_report_and_checks(api: SandboxAPI):
assert route.calls.last.request.headers["Authorization"] == "Bearer t-test"
assert report.ok is True
assert report.active_provider == "aws"
assert report.tailscale_enabled is True
assert report.tailnet is True
assert [check.name for check in report.checks] == ["db", "provider", "tailscale"]
provider = next(check for check in report.checks if check.name == "provider")
assert provider.status == "ok"
Expand Down
Loading