Gateway: pytest suite #8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Gateway service (see #18). Test conventions follow the beets plugin's
tests/(FakeResponse/FakeSession classes, no network).Task
A
tests/suite covering:Apple-401 -> 502 re-login hint
(ported from the plugin tests)
Dev deps:
pytest>=8,httpx(FastAPI TestClient). Add[tool.pytest.ini_options] testpaths = ["tests"].Acceptance criteria
uv run pytestgreen; no test makes a real network call.Done.
uv run pytestis green (62 passed, no network calls). The suite lives intests/and covers everything on the checklist:test_apple_auth.py— ES256 signing with a generated P-256 key, caching within the 30-day threshold, refresh past it (incl. exact-threshold boundary), unreadable/garbage keys, no token in repr, concurrencytest_credential_store.py— round-trip, clear, owner-only 0o600 creation, permission warnings (world/group-readable), no auto-chmod, upsert keeps one row, lazy reads never create the filetest_login_routes.py— login page embeds a fresh valid dev token + redirect target; callback captures the token without echoing it; token absent from app logs and access-log query strings scrubbedtest_api_routes.py— bearer rejection (401 on all four routes, wrong token), status/playlists/tracks/logout, Apple 401/403 -> 502 re-login hint, missing token -> 502test_apple_api.py— pagination offsets, nested-playlist splicing, music-video skipping, 429 retry, status_code on AppleAPIErrortest_config.py+test_healthz.py— env parsing, fail-fast startup naming missing vars, healthzDev deps (
pytest>=8,httpx) and[tool.pytest.ini_options] testpaths = ["tests"]are inpyproject.toml.