Coverage for tests/test_tutorial/test_metadata/test_tutorial001_1.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi.testclient import TestClient 1abcde

2 

3from docs_src.metadata.tutorial001_1 import app 1abcde

4 

5client = TestClient(app) 1abcde

6 

7 

8def test_items(): 1abcde

9 response = client.get("/items/") 1abcde

10 assert response.status_code == 200, response.text 1abcde

11 assert response.json() == [{"name": "Katana"}] 1abcde

12 

13 

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": { 

20 "title": "ChimichangApp", 

21 "summary": "Deadpool's favorite app. Nuff said.", 

22 "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", 

23 "termsOfService": "http://example.com/terms/", 

24 "contact": { 

25 "name": "Deadpoolio the Amazing", 

26 "url": "http://x-force.example.com/contact/", 

27 "email": "dp@x-force.example.com", 

28 }, 

29 "license": { 

30 "name": "Apache 2.0", 

31 "identifier": "MIT", 

32 }, 

33 "version": "0.0.1", 

34 }, 

35 "paths": { 

36 "/items/": { 

37 "get": { 

38 "summary": "Read Items", 

39 "operationId": "read_items_items__get", 

40 "responses": { 

41 "200": { 

42 "description": "Successful Response", 

43 "content": {"application/json": {"schema": {}}}, 

44 } 

45 }, 

46 } 

47 } 

48 }, 

49 }