From c9c24d3ca5cfbe82b60b52682d68bd7bc5f57b86 Mon Sep 17 00:00:00 2001 From: alv2017 Date: Tue, 11 Mar 2025 00:34:55 +0200 Subject: [PATCH] New tests added: tutorial:Path Parameters, tests/test_tutorial/test_path_params/test_tutorial003.py --- .../test_path_params/test_tutorial003.py | 22 +++++++++++++++++++ 1 file changed, 22 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..6d15e2c47 --- /dev/null +++ b/tests/test_tutorial/test_path_params/test_tutorial003.py @@ -0,0 +1,22 @@ +import pytest +from fastapi.testclient import TestClient + +from docs_src.path_params.tutorial003 import app + + +@pytest.fixture(name="client") +def get_client(): + return TestClient(app) + + +def test_get_users_me_is_responding_as_expected(client): + response = client.get("/users/me") + assert response.status_code == 200 + assert response.json() == {"user_id": "the current user"} + + +def test_get_users_user_id_is_responding_as_expected(client): + user_id = "ADMIN001" + response = client.get(f"/users/{user_id}") + assert response.status_code == 200 + assert response.json() == {"user_id": user_id}