Coverage for tests/test_tutorial/test_path_operation_configurations/test_tutorial002b.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi.testclient import TestClient 1abcde
3from docs_src.path_operation_configuration.tutorial002b import app 1abcde
5client = TestClient(app) 1abcde
8def test_get_items(): 1abcde
9 response = client.get("/items/") 1abcde
10 assert response.status_code == 200, response.text 1abcde
11 assert response.json() == ["Portal gun", "Plumbus"] 1abcde
14def test_get_users(): 1abcde
15 response = client.get("/users/") 1abcde
16 assert response.status_code == 200, response.text 1abcde
17 assert response.json() == ["Rick", "Morty"] 1abcde
20def test_openapi_schema(): 1abcde
21 response = client.get("/openapi.json") 1abcde
22 assert response.status_code == 200, response.text 1abcde
23 assert response.json() == { 1abcde
24 "openapi": "3.1.0",
25 "info": {"title": "FastAPI", "version": "0.1.0"},
26 "paths": {
27 "/items/": {
28 "get": {
29 "tags": ["items"],
30 "summary": "Get Items",
31 "operationId": "get_items_items__get",
32 "responses": {
33 "200": {
34 "description": "Successful Response",
35 "content": {"application/json": {"schema": {}}},
36 }
37 },
38 }
39 },
40 "/users/": {
41 "get": {
42 "tags": ["users"],
43 "summary": "Read Users",
44 "operationId": "read_users_users__get",
45 "responses": {
46 "200": {
47 "description": "Successful Response",
48 "content": {"application/json": {"schema": {}}},
49 }
50 },
51 }
52 },
53 },
54 }