Debian Codegraph @

tests/test_tutorial/test_metadata/test_tutorial002.py

raw
1 from fastapi.testclient import TestClient
2 from inline_snapshot import snapshot
3
4 from docs_src.metadata.tutorial002_py310 import app
5
6 client = TestClient(app)
7
8
9 def test_items():
10 response = client.get("/items/")
11 assert response.status_code == 200, response.text
12 assert response.json() == [{"name": "Foo"}]
13
14
15 def test_get_openapi_json_default_url():
16 response = client.get("/openapi.json")
17 assert response.status_code == 404, response.text
18
19
20 def test_openapi_schema():
21 response = client.get("/api/v1/openapi.json")
22 assert response.status_code == 200, response.text
23 assert response.json() == snapshot(
24 {
25 "openapi": "3.1.0",
26 "info": {
27 "title": "FastAPI",
28 "version": "0.1.0",
29 },
30 "paths": {
31 "/items/": {
32 "get": {
33 "summary": "Read Items",
34 "operationId": "read_items_items__get",
35 "responses": {
36 "200": {
37 "description": "Successful Response",
38 "content": {"application/json": {"schema": {}}},
39 }
40 },
41 }
42 }
43 },
44 }
45 )