feat(rulebook): REST routes — rulebook + topic endpoints
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""Route-level tests for the rulebooks blueprint.
|
||||
|
||||
Mirrors the structural-tests pattern in tests/test_events_routes.py:
|
||||
covers blueprint registration, callable handlers, and service-signature
|
||||
contracts. Full HTTP integration requires a live DB and auth machinery
|
||||
that the unit-test environment doesn't provide.
|
||||
"""
|
||||
import inspect
|
||||
|
||||
|
||||
def test_rulebooks_blueprint_registered():
|
||||
from fabledassistant.routes.rulebooks import rulebooks_bp
|
||||
assert rulebooks_bp.name == "rulebooks"
|
||||
assert rulebooks_bp.url_prefix == "/api"
|
||||
|
||||
|
||||
def test_rulebooks_blueprint_registered_in_app():
|
||||
from fabledassistant.app import create_app
|
||||
app = create_app()
|
||||
assert "rulebooks" in app.blueprints
|
||||
|
||||
|
||||
def test_rulebook_handlers_callable():
|
||||
from fabledassistant.routes import rulebooks as rb_routes
|
||||
for name in (
|
||||
"list_rulebooks", "create_rulebook", "get_rulebook",
|
||||
"update_rulebook", "delete_rulebook",
|
||||
):
|
||||
assert callable(getattr(rb_routes, name))
|
||||
|
||||
|
||||
def test_topic_handlers_callable():
|
||||
from fabledassistant.routes import rulebooks as rb_routes
|
||||
for name in (
|
||||
"list_topics", "create_topic", "update_topic", "delete_topic",
|
||||
):
|
||||
assert callable(getattr(rb_routes, name))
|
||||
|
||||
|
||||
def test_service_signatures_require_user_id():
|
||||
"""Routes must call services with user_id — verify the contract."""
|
||||
from fabledassistant.services import rulebooks as svc
|
||||
for fn_name in (
|
||||
"create_rulebook", "list_rulebooks", "get_rulebook",
|
||||
"update_rulebook", "delete_rulebook", "find_rulebook_by_title",
|
||||
"create_topic", "list_topics", "get_topic", "update_topic", "delete_topic",
|
||||
):
|
||||
sig = inspect.signature(getattr(svc, fn_name))
|
||||
assert "user_id" in sig.parameters, f"{fn_name} missing user_id param"
|
||||
Reference in New Issue
Block a user