Coverage for tests / test_tutorial / test_metadata / test_tutorial004.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi.testclient import TestClient 1abcd
2from inline_snapshot import snapshot 1abcd
4from docs_src.metadata.tutorial004_py310 import app 1abcd
6client = TestClient(app) 1abcd
9def test_path_operations(): 1abcd
10 response = client.get("/items/") 1efg
11 assert response.status_code == 200, response.text 1efg
12 response = client.get("/users/") 1efg
13 assert response.status_code == 200, response.text 1efg
16def test_openapi_schema(): 1abcd
17 response = client.get("/openapi.json") 1hij
18 assert response.status_code == 200, response.text 1hij
19 assert response.json() == snapshot( 1hij
20 {
21 "openapi": "3.1.0",
22 "info": {"title": "FastAPI", "version": "0.1.0"},
23 "paths": {
24 "/users/": {
25 "get": {
26 "tags": ["users"],
27 "summary": "Get Users",
28 "operationId": "get_users_users__get",
29 "responses": {
30 "200": {
31 "description": "Successful Response",
32 "content": {"application/json": {"schema": {}}},
33 }
34 },
35 }
36 },
37 "/items/": {
38 "get": {
39 "tags": ["items"],
40 "summary": "Get Items",
41 "operationId": "get_items_items__get",
42 "responses": {
43 "200": {
44 "description": "Successful Response",
45 "content": {"application/json": {"schema": {}}},
46 }
47 },
48 }
49 },
50 },
51 "tags": [
52 {
53 "name": "users",
54 "description": "Operations with users. The **login** logic is also here.",
55 },
56 {
57 "name": "items",
58 "description": "Manage items. So _fancy_ they have their own docs.",
59 "externalDocs": {
60 "description": "Items external docs",
61 "url": "https://fastapi.tiangolo.com/",
62 },
63 },
64 ],
65 }
66 )