Coverage for app/api/v1/endpoints/setup_router.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-16 20:06 +0000

1from fastapi import APIRouter 

2from app.api.v1.dependencies import SetupServiceDependency 

3from app.schemas.setup import SetupRequest, SetupResponse 

4 

5 

6setup_router = APIRouter() 

7 

8 

9@setup_router.post( 

10 "", 

11 response_model=SetupResponse, 

12 status_code=200, 

13 summary="Initialize a Mars probe on the grid", 

14 response_description="Details of the newly created probe, including its generated id, coordinates, and direction.", 

15 description=( 

16 "Create a new Mars probe on the grid using the SetupService.\n\n" 

17 "### Request\n" 

18 "- `x` and `y`: grid dimensions\n" 

19 "- `direction`: initial cardinal orientation\n\n" 

20 "### Behavior\n" 

21 "- The probe starts at coordinate `(0, 0)` on the grid.\n" 

22 "- Grid dimensions must be non-negative integers, and at least one dimension must be greater than zero.\n\n" 

23 "### Result\n" 

24 "- Returns the created probe state as a `SetupResponse`.\n" 

25 "- The SetupService uses ProbeRepository to persist the probe and its grid position." 

26 ), 

27 responses={ 

28 200: { 

29 "description": "Probe initialized successfully on valid grid", 

30 "model": SetupResponse, 

31 }, 

32 500: { 

33 "description": "Unexpected server error.", 

34 "content": { 

35 "application/json": { 

36 "example": { 

37 "detail": { 

38 "code": "SETUP_UNEXPECTED_ERROR", 

39 "message": "Unexpected error. Try again in a few seconds.", 

40 } 

41 } 

42 } 

43 }, 

44 }, 

45 }, 

46) 

47async def setup_probe(setup: SetupRequest, service: SetupServiceDependency): 

48 """ 

49 Initialize a Mars probe at the specified coordinates and direction. 

50 """ 

51 return await service.process(setup)