Debian Codegraph @

tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial005.py

raw
1 from fastapi.testclient import TestClient
2 from inline_snapshot import snapshot
3
4 from docs_src.path_operation_advanced_configuration.tutorial005_py310 import app
5
6 client = TestClient(app)
7
8
9 def test_get():
10 response = client.get("/items/")
11 assert response.status_code == 200, response.text
12
13
14 def test_openapi_schema():
15 response = client.get("/openapi.json")
16 assert response.status_code == 200, response.text
17 assert response.json() == snapshot(
18 {
19 "openapi": "3.1.0",
20 "info": {"title": "FastAPI", "version": "0.1.0"},
21 "paths": {
22 "/items/": {
23 "get": {
24 "responses": {
25 "200": {
26 "description": "Successful Response",
27 "content": {"application/json": {"schema": {}}},
28 }
29 },
30 "summary": "Read Items",
31 "operationId": "read_items_items__get",
32 "x-aperture-labs-portal": "blue",
33 }
34 }
35 },
36 }
37 )