Coverage for docs_src/extra_data_types/tutorial001.py: 100%

10 statements  

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

1from datetime import datetime, time, timedelta 1abcde

2from typing import Union 1abcde

3from uuid import UUID 1abcde

4 

5from fastapi import Body, FastAPI 1abcde

6 

7app = FastAPI() 1abcde

8 

9 

10@app.put("/items/{item_id}") 1abcde

11async def read_items( 1abcde

12 item_id: UUID, 

13 start_datetime: datetime = Body(), 

14 end_datetime: datetime = Body(), 

15 process_after: timedelta = Body(), 

16 repeat_at: Union[time, None] = Body(default=None), 

17): 

18 start_process = start_datetime + process_after 1abcde

19 duration = end_datetime - start_process 1abcde

20 return { 1abcde

21 "item_id": item_id, 

22 "start_datetime": start_datetime, 

23 "end_datetime": end_datetime, 

24 "process_after": process_after, 

25 "repeat_at": repeat_at, 

26 "start_process": start_process, 

27 "duration": duration, 

28 }