Files
inkwell/tests/test_app.py
T
bvandeusenandClaude Opus 5.5 b74dc7c1fe
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 2s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Skipped
Desktop (Tauri) / Tauri desktop (Linux) (push) Skipped
Desktop (Tauri) / Windows installer (cross-compiled) (push) Skipped
Desktop (Tauri) / Update manifest (push) Skipped
CI & Build / Web typecheck and unit tests (push) Successful in 8s
CI & Build / Python tests (push) Successful in 13s
Android / Core and FFI clippy and tests (push) Successful in 25s
CI & Build / integration (push) Successful in 1m31s
CI & Build / Build & push image (push) Skipped
Android / Kotlin + Rust (APK) (push) Successful in 6m41s
Android / Build the server image (push) Successful in 1s
One app fixture for the tests, and ViewModels built where they are used
The tests' `app` fixture, the same two lines in eleven files, now lives once in
tests/conftest.py.

On Android each ViewModel carried a companion `factory` that only wrapped its
constructor in viewModelFactory { initializer { … } }. MainActivity now builds
each one with Compose's viewModel { … } builder, so the five factories and their
imports are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 21:25:05 -04:00

67 lines
2.2 KiB
Python

from inkwell.app import create_app
async def test_health_ok(app):
client = app.test_client()
resp = await client.get("/api/health")
assert resp.status_code == 200
data = await resp.get_json()
assert data["status"] == "ok"
assert "version" in data
async def test_me_requires_auth(app):
client = app.test_client()
resp = await client.get("/api/auth/me")
assert resp.status_code == 401
async def test_unknown_api_route_404s(app):
client = app.test_client()
resp = await client.get("/api/does-not-exist")
assert resp.status_code == 404
# --- the version a running server reports ------------------------------------
#
# The only answer to "which build is this?", so the fallback matters most: it must
# be "unknown", never a plausible-looking `__version__`.
async def reported_version() -> str:
"""What a freshly built app tells /api/health it is.
Built per call rather than through the `app` fixture: the value is read from the
environment in `create_app`, so an app constructed before `monkeypatch` ran would
answer about the wrong environment.
"""
client = create_app().test_client()
return (await (await client.get("/api/health")).get_json())["version"]
async def test_the_version_is_whatever_the_environment_says(monkeypatch):
monkeypatch.setenv("APP_VERSION", "2026.08.29.0443")
assert await reported_version() == "2026.08.29.0443"
async def test_no_version_in_the_environment_reports_unknown(monkeypatch):
"""The honest "I cannot say", not a plausible default.
Also asserted against `__version__` by name rather than against the literal it
happens to hold, so bumping the packaging version cannot make this pass for the
wrong reason.
"""
from inkwell import __version__
monkeypatch.delenv("APP_VERSION", raising=False)
reported = await reported_version()
assert reported == "unknown"
assert reported != __version__
async def test_an_empty_version_reports_unknown_too(monkeypatch):
"""`APP_VERSION=` is what a mis-set build arg looks like, and an empty string
renders as a blank space rather than as a missing value."""
monkeypatch.setenv("APP_VERSION", "")
assert await reported_version() == "unknown"