From 7b75d820ad1bf85487d04611ef3d09c15ca19f20 Mon Sep 17 00:00:00 2001 From: Felipe Carvajal Date: Mon, 23 Feb 2026 23:24:48 -0300 Subject: [PATCH] added test for router mount --- tests/test_router_mount.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_router_mount.py diff --git a/tests/test_router_mount.py b/tests/test_router_mount.py new file mode 100644 index 0000000000..0a36544c9f --- /dev/null +++ b/tests/test_router_mount.py @@ -0,0 +1,20 @@ +from fastapi import FastAPI, APIRouter +from fastapi.testclient import TestClient + +app = FastAPI() +api_router = APIRouter(prefix="/api") + +@api_router.get("/app") +def read_main(): + return {"message": "Hello World from main app"} + +subapi = FastAPI() + +@subapi.get("/sub") +def read_sub(): + return {"message": "Hello World from sub API"} + +api_router.mount("/subapi", subapi) # ← moved up +app.include_router(api_router) # ← now after + +print("All tests passed.") \ No newline at end of file