Coverage for app/services/check_service.py: 100%
13 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-16 20:06 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-16 20:06 +0000
1from app.schemas.check import CheckResponse
2from app.repositories.probe_repository import ProbeRepository
3from app.schemas.probe import ProbeResponse
4from fastapi import HTTPException
7class CheckService:
8 def __init__(
9 self,
10 repository: ProbeRepository,
11 ) -> None:
12 self.repository = repository
14 async def process(
15 self,
16 ) -> CheckResponse:
17 try:
18 probes = [
19 ProbeResponse(
20 id=probe.id, x=probe.x, y=probe.y, direction=probe.direction
21 )
22 for probe in await self.repository.find_all()
23 ]
24 return CheckResponse(probes=list(probes))
25 except Exception:
26 raise HTTPException(
27 status_code=500,
28 detail={
29 "code": "CHECK_UNEXPECTED_ERROR",
30 "message": "Unexpected error. Try again in a few seconds.",
31 },
32 )