Coverage for tests/test_tutorial/test_metadata/test_tutorial004.py: 100%
12 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.metadata.tutorial004 import app 1abcde
5client = TestClient(app) 1abcde
8def test_path_operations(): 1abcde
9 response = client.get("/items/") 1abcde
10 assert response.status_code == 200, response.text 1abcde
11 response = client.get("/users/") 1abcde
12 assert response.status_code == 200, response.text 1abcde
15def test_openapi_schema(): 1abcde
16 response = client.get("/openapi.json") 1abcde
17 assert response.status_code == 200, response.text 1abcde
18 assert response.json() == { 1abcde
19 "openapi": "3.1.0",
20 "info": {"title": "FastAPI", "version": "0.1.0"},
21 "paths": {
22 "/users/": {
23 "get": {
24 "tags": ["users"],
25 "summary": "Get Users",
26 "operationId": "get_users_users__get",
27 "responses": {
28 "200": {
29 "description": "Successful Response",
30 "content": {"application/json": {"schema": {}}},
31 }
32 },
33 }
34 },
35 "/items/": {
36 "get": {
37 "tags": ["items"],
38 "summary": "Get Items",
39 "operationId": "get_items_items__get",
40 "responses": {
41 "200": {
42 "description": "Successful Response",
43 "content": {"application/json": {"schema": {}}},
44 }
45 },
46 }
47 },
48 },
49 "tags": [
50 {
51 "name": "users",
52 "description": "Operations with users. The **login** logic is also here.",
53 },
54 {
55 "name": "items",
56 "description": "Manage items. So _fancy_ they have their own docs.",
57 "externalDocs": {
58 "description": "Items external docs",
59 "url": "https://fastapi.tiangolo.com/",
60 },
61 },
62 ],
63 }