mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-10-30 00:27:11 +09:00
Toasts showed backend prose verbatim, with no code to translate against and "application" where the UI says "service". Not-found, missing-field, permission, conflict and agent-offline errors now come from factories in app/exceptions.py that pair one fixed message with a dotted code (not_found.<resource>, validation.required, permission.denied, conflict.exists, agent.offline), so the client can translate them. The shared app-loading helpers and the apps, domains, servers, databases and backups routes raise those errors instead of hand shaping bodies, which drops the hand-shaped body count from 1132 to 850. Five routes picked an HTTP status by comparing error text; they now key off a result code or a sentinel so rewording can't change a status. Five broad excepts that echoed str(exc) now log the crash and return the request id instead.
26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
"""§8 Phase B4 — /config-checkpoints aliases /snapshots.
|
|
|
|
"Config Checkpoint" is the user-facing name for a deployment config snapshot.
|
|
The snapshots blueprint serves every route under both /snapshots and
|
|
/config-checkpoints so the API matches the new wording while old callers keep
|
|
working.
|
|
"""
|
|
|
|
|
|
def test_config_checkpoints_resolves_same_handler(app, client, auth_headers):
|
|
# Both prefixes hit the same view, so a missing app produces the identical
|
|
# 404 response on either — proof the alias resolves to the same handler.
|
|
snaps = client.get('/api/v1/apps/999999/snapshots', headers=auth_headers)
|
|
ckpts = client.get('/api/v1/apps/999999/config-checkpoints', headers=auth_headers)
|
|
assert snaps.status_code == 404
|
|
assert ckpts.status_code == 404
|
|
# Same body apart from the per-request id the typed error carries.
|
|
strip = lambda body: {k: v for k, v in body.items() if k != 'request_id'} # noqa: E731
|
|
assert strip(ckpts.get_json()) == strip(snaps.get_json())
|
|
|
|
|
|
def test_both_route_spaces_registered(route_rules):
|
|
# route_rules is the session app's url_map (plan 77 G3) — no second boot.
|
|
assert any('/snapshots' in r for r in route_rules)
|
|
assert any('/config-checkpoints' in r for r in route_rules)
|