DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
test(api): preserve auth dependencies for eager preview routes
Bingxi Zhao (Frank)467d0adba249
diff --git a/tests/api/test_file_preview.py b/tests/api/test_file_preview.pyindex 1c5771082..3bc6f8093 100644--- a/tests/api/test_file_preview.py+++ b/tests/api/test_file_preview.py@@ -33,7 +33,7 @@ def _file_preview_routes(app):nested = getattr(route, "original_router", None)if nested is None:if getattr(route, "path", "") == "/api/file-preview/pdf":- flattened.append(SimpleNamespace(dependant=route.dependant))+ flattened.append(SimpleNamespace(dependencies=list(route.dependant.dependencies)))continuectx = getattr(route, "include_context", None)prefix = str(getattr(ctx, "prefix", "") or "")@@ -46,6 +46,36 @@ def _file_preview_routes(app):return flattened[email protected]("lazy", [False, True])+def test_file_preview_route_normalizer_keeps_auth_dependency(lazy: bool) -> None:+ from fastapi import Depends++ from deeptutor.api.routers.auth import require_auth++ eager_dependency = SimpleNamespace(call=require_auth)+ if lazy:+ inner = SimpleNamespace(path="/pdf", dependant=SimpleNamespace(dependencies=[]))+ route = SimpleNamespace(+ original_router=SimpleNamespace(routes=[inner]),+ include_context=SimpleNamespace(+ prefix="/api/file-preview", dependencies=[Depends(require_auth)]+ ),+ )+ else:+ route = SimpleNamespace(+ path="/api/file-preview/pdf",+ dependant=SimpleNamespace(dependencies=[eager_dependency]),+ )++ normalized = _file_preview_routes(SimpleNamespace(routes=[route]))+ assert len(normalized) == 1+ assert any(+ (getattr(dependency, "call", None) or getattr(dependency, "dependency", None))+ is require_auth+ for dependency in normalized[0].dependencies+ )++def test_preview_route_requires_authentication(monkeypatch) -> None:from deeptutor.api.main import appfrom deeptutor.api.routers import auth