Coverage for tests/test_tutorial/test_extra_models/test_tutorial005_py39.py: 100%
18 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
1import pytest 1eabcd
2from fastapi.testclient import TestClient 1eabcd
4from ...utils import needs_py39 1eabcd
7@pytest.fixture(name="client") 1eabcd
8def get_client(): 1eabcd
9 from docs_src.extra_models.tutorial005_py39 import app 1abcd
11 client = TestClient(app) 1abcd
12 return client 1abcd
15@needs_py39 1eabcd
16def test_get_items(client: TestClient): 1eabcd
17 response = client.get("/keyword-weights/") 1abcd
18 assert response.status_code == 200, response.text 1abcd
19 assert response.json() == {"foo": 2.3, "bar": 3.4} 1abcd
22@needs_py39 1eabcd
23def test_openapi_schema(client: TestClient): 1eabcd
24 response = client.get("/openapi.json") 1abcd
25 assert response.status_code == 200, response.text 1abcd
26 assert response.json() == { 1abcd
27 "openapi": "3.1.0",
28 "info": {"title": "FastAPI", "version": "0.1.0"},
29 "paths": {
30 "/keyword-weights/": {
31 "get": {
32 "responses": {
33 "200": {
34 "description": "Successful Response",
35 "content": {
36 "application/json": {
37 "schema": {
38 "title": "Response Read Keyword Weights Keyword Weights Get",
39 "type": "object",
40 "additionalProperties": {"type": "number"},
41 }
42 }
43 },
44 }
45 },
46 "summary": "Read Keyword Weights",
47 "operationId": "read_keyword_weights_keyword_weights__get",
48 }
49 }
50 },
51 }