Files
DeepTutor/tests/api/test_websocket_routing.py
Bingxi Zhao (Frank) 6e6e56aedb release: v1.6.3
Ship the breaking front- and back-end runtime and route refactor,
learner and guardian flows, grounded reading, knowledge and parser
updates, and recoverable long-running streams.

Release notes: assets/releases/ver1-6-3.md
2026-09-02 04:09:11 +08:00

33 lines
992 B
Python

"""WebSocket routes must not inherit HTTP-only application dependencies."""
from fastapi.routing import APIWebSocketRoute
from deeptutor.api.main import app
from deeptutor.api.routers.auth import require_learning_surface
def test_websocket_routes_share_one_canonical_namespace() -> None:
expected_paths = {
"/ws",
"/ws/books",
"/ws/questions/mimic",
"/ws/questions/generate",
"/ws/questions/judge",
"/ws/knowledge-bases/{kb_name}/progress",
"/ws/mastery-paths",
"/ws/partners/{partner_id}",
"/ws/partner-groups/{group_id}",
}
websocket_routes = {
route.path: route
for route in app.routes
if isinstance(route, APIWebSocketRoute)
}
assert set(websocket_routes) == expected_paths
for route in websocket_routes.values():
assert all(
dependency.call is not require_learning_surface
for dependency in route.dependant.dependencies
)