Coverage for tests/test_tutorial/test_extra_models/test_tutorial005.py: 100%
11 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.extra_models.tutorial005 import app 1abcde
5client = TestClient(app) 1abcde
8def test_get_items(): 1abcde
9 response = client.get("/keyword-weights/") 1abcde
10 assert response.status_code == 200, response.text 1abcde
11 assert response.json() == {"foo": 2.3, "bar": 3.4} 1abcde
14def test_openapi_schema(): 1abcde
15 response = client.get("/openapi.json") 1abcde
16 assert response.status_code == 200, response.text 1abcde
17 assert response.json() == { 1abcde
18 "openapi": "3.1.0",
19 "info": {"title": "FastAPI", "version": "0.1.0"},
20 "paths": {
21 "/keyword-weights/": {
22 "get": {
23 "responses": {
24 "200": {
25 "description": "Successful Response",
26 "content": {
27 "application/json": {
28 "schema": {
29 "title": "Response Read Keyword Weights Keyword Weights Get",
30 "type": "object",
31 "additionalProperties": {"type": "number"},
32 }
33 }
34 },
35 }
36 },
37 "summary": "Read Keyword Weights",
38 "operationId": "read_keyword_weights_keyword_weights__get",
39 }
40 }
41 },
42 }