Files
inkwell/tests/test_app.py
T
bvandeusenandClaude Opus 5.5 a51a563fe7
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
Android / Core and FFI clippy and tests (push) Skipped
Android / Kotlin + Rust (APK) (push) Skipped
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 13s
Android / Build the server image (push) Skipped
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 / integration (push) Successful in 1m30s
CI & Build / Build & push image (push) Successful in 32s
Server comments describe the code to a stranger (#6221)
Rule 32 "Comments describe the product to a stranger" sweep over
src/, alembic/ and tests/. Comments and docstrings now say what the code
does and the reason as a present-tense constraint, briefly.

Removed:
- issue, task, note, rule, milestone and family-idea references
- "used to" / before-and-after narration
- quotes of decisions and incident stories from the deploying instance
- paragraph-length arguments, where a line or two carries the fact

Kept every hazard as a present-tense fact, e.g. timing oracles, the
proxy hop direction, and migrations that must stay frozen.

Also:
- Three test names lose "still"/"used to"/"pre_m304" phrasing.
- pyproject's description drops "FabledSword family".

The history these comments carried stays in Scribe and in git log.
A comment-stripping diff (Scribe snippet #6226 "codeonly.py — prove a
diff changed only comments") shows no code changed apart from the
renamed tests and the description string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 20:07:47 -04:00

74 lines
2.3 KiB
Python

import pytest
from inkwell.app import create_app
@pytest.fixture
def app():
return 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"