Coverage for opt/mealie/lib/python3.12/site-packages/mealie/schema/response/responses.py: 95%
20 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 15:32 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 15:32 +0000
1from pydantic import BaseModel 1a
3from mealie.schema._mealie import MealieModel 1a
6class ErrorResponse(BaseModel): 1a
7 message: str 1a
8 error: bool = True 1a
9 exception: str | None = None 1a
11 @classmethod 1a
12 def respond(cls, message: str, exception: str | None = None) -> dict: 1a
13 """
14 This method is an helper to create an object and convert to a dictionary
15 in the same call, for use while providing details to a HTTPException
16 """
17 return cls(message=message, exception=exception).model_dump() 1bcdefghijkl
20class SuccessResponse(BaseModel): 1a
21 message: str 1a
22 error: bool = False 1a
24 @classmethod 1a
25 def respond(cls, message: str = "") -> dict: 1a
26 """
27 This method is an helper to create an object and convert to a dictionary
28 in the same call, for use while providing details to a HTTPException
29 """
30 return cls(message=message).model_dump() 1b
33class FileTokenResponse(MealieModel): 1a
34 file_token: str 1a
36 @classmethod 1a
37 def respond(cls, token: str) -> dict: 1a
38 """
39 This method is an helper to create an object and convert to a dictionary
40 in the same call, for use while providing details to a HTTPException
41 """
42 return cls(file_token=token).model_dump()