From 219d098f77deb42ac9059468ebfa2ef3e63bd798 Mon Sep 17 00:00:00 2001 From: Mgcsuper <152525588+Mgcsuper@users.noreply.github.com> Date: Fri, 19 Apr 2024 07:39:36 +0200 Subject: [PATCH] Create fastapi/tests/test_tutorial/test_path_params /test_tutorial003.py It can be interesting to note that although we have created two queries with the same path there are still two roots, one does not overwrite the other --- .../test_path_params/test_tutorial003.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_tutorial/test_path_params/test_tutorial003.py diff --git a/tests/test_tutorial/test_path_params/test_tutorial003.py b/tests/test_tutorial/test_path_params/test_tutorial003.py new file mode 100644 index 000000000..fc17379d5 --- /dev/null +++ b/tests/test_tutorial/test_path_params/test_tutorial003.py @@ -0,0 +1,20 @@ +from fastapi.testclient import TestClient +from fastapi.routing import APIRoute + +import docs_src.path_params.tutorial003 as t3 + +client = TestClient(t3.app) + + +def test_get_users(): + response = client.get("/users") + print(response.json()) + assert response.status_code == 200 + assert response.json() == {"user_id": "the current user"} + + +def test_routes_created(): + root1 = APIRoute(path='/users', endpoint=t3.read_user, methods=['GET'], name = "name='read_user") + root2 = APIRoute(path='/users', endpoint=t3.read_user_me, methods=['GET'], name = "name='read_user_me'") + assert (root1 in t3.app.router.routes) and (root2 in t3.app.router.routes) +