Debian Codegraph @

tests/test_tutorial/test_metadata/test_tutorial001.py

raw
1 from fastapi.testclient import TestClient
2 from inline_snapshot import snapshot
3
4 from docs_src.metadata.tutorial001_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": "Katana"}]
13
14
15 def test_openapi_schema():
16 response = client.get("/openapi.json")
17 assert response.status_code == 200, response.text
18 assert response.json() == snapshot(
19 {
20 "openapi": "3.1.0",
21 "info": {
22 "title": "ChimichangApp",
23 "summary": "Deadpool's favorite app. Nuff said.",
24 "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
25 "termsOfService": "http://example.com/terms/",
26 "contact": {
27 "name": "Deadpoolio the Amazing",
28 "url": "http://x-force.example.com/contact/",
29 "email": "[email protected]",
30 },
31 "license": {
32 "name": "Apache 2.0",
33 "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
34 },
35 "version": "0.0.1",
36 },
37 "paths": {
38 "/items/": {
39 "get": {
40 "summary": "Read Items",
41 "operationId": "read_items_items__get",
42 "responses": {
43 "200": {
44 "description": "Successful Response",
45 "content": {"application/json": {"schema": {}}},
46 }
47 },
48 }
49 }
50 },
51 }
52 )