"""Structural tests for the snippets blueprint — registration + handler/service contracts. Full HTTP integration needs a live DB + auth the unit env lacks.""" import inspect def test_snippets_blueprint_registered(): from scribe.routes.snippets import snippets_bp assert snippets_bp.name == "snippets" assert snippets_bp.url_prefix == "/api/snippets" def test_snippets_blueprint_registered_in_app(): from scribe.app import create_app app = create_app() assert "snippets" in app.blueprints def test_snippet_handlers_callable(): from scribe.routes import snippets as routes for name in ( "list_snippets_route", "create_snippet_route", "get_snippet_route", "update_snippet_route", "delete_snippet_route", ): assert callable(getattr(routes, name)) def test_service_functions_take_user_id(): """Routes must call snippet services with user_id — verify the contract.""" from scribe.services import snippets as svc for fn_name in ("create_snippet", "list_snippets", "get_snippet", "update_snippet"): fn = getattr(svc, fn_name) assert callable(fn) assert "user_id" in inspect.signature(fn).parameters def test_update_field_map_matches_service_kwargs(): """Every field the PATCH route forwards must be a real update_snippet kwarg (rule #33 interface-contract parity).""" from scribe.routes import snippets as routes from scribe.services import snippets as svc params = inspect.signature(svc.update_snippet).parameters for field in routes._STR_FIELDS: assert field in params, f"update_snippet has no '{field}' kwarg" assert "tags" in params assert "project_id" in params