test(8249): the caller-scoping contract is a property of the services, not four lists of names

Review of the signature-flagged tests:
- Four route files each listed service names by hand and checked each takes
  user_id. A new service without the caller passed them, and a renamed one
  failed them. They become one test over services/{design_systems,systems,
  rulebooks,snippets}.py: every public coroutine takes user_id, except eight
  named with the reason each needs none, and an exception for a function that
  is gone or now takes the caller fails too.
- test_routes_trash was four existence checks: blueprint name, registered,
  handlers callable, the service surface, delete's parameter names. It
  becomes one check that the three trash routes are on the app; what they do
  is proven by test_services_trash and test_mcp_tool_trash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 07:06:32 -05:00
co-authored by Claude Opus 5.5
parent f4f036c8a7
commit 5d764ecf2f
6 changed files with 69 additions and 86 deletions
+11 -29
View File
@@ -1,32 +1,14 @@
"""Structural tests for the trash blueprint + delete-flip contracts."""
import inspect
"""The trash API is routed: list, restore and purge reach handlers on the
running app. What they do is the trash service's to prove
(tests/test_services_trash.py, tests/test_mcp_tool_trash.py)."""
def test_trash_blueprint_registered():
from grimoire.routes.trash import trash_bp
assert trash_bp.name == "trash"
assert trash_bp.url_prefix == "/api/trash"
def test_trash_blueprint_registered_in_app():
def test_the_trash_routes_are_on_the_app():
from grimoire.app import create_app
app = create_app()
assert "trash" in app.blueprints
def test_trash_handlers_callable():
from grimoire.routes import trash as trash_routes
for name in ("list_trash", "restore_batch", "purge_batch"):
assert callable(getattr(trash_routes, name))
def test_trash_service_surface():
from grimoire.services import trash as svc
for fn_name in ("delete", "restore", "purge", "list_trash", "purge_expired", "alive"):
assert hasattr(svc, fn_name), f"trash service missing {fn_name}"
def test_delete_service_signature():
from grimoire.services.trash import delete
params = inspect.signature(delete).parameters
assert "user_id" in params and "entity_type" in params and "entity_id" in params
rules = {
(str(r.rule), m) for r in create_app().url_map.iter_rules() for m in r.methods
}
for route in (("/api/trash", "GET"),
("/api/trash/<batch_id>/restore", "POST"),
("/api/trash/<batch_id>", "DELETE")):
assert route in rules, route