Coverage for app/ddd/presentation/schema/group/group_request.py: 93%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-15 01:44 +0000

1 

2 

3from typing import Any 

4 

5# from sqlmodel import Field 

6from pydantic import Field, validator 

7 

8from app.core.base import BaseRequest 

9from app.ddd.infrastructure.util.convert import recursive_to_snake 

10 

11 

12class CreateGroupRequest(BaseRequest): 

13 group_name: str 

14 

15# class PatchGroupsRequest(BaseRequest): 

16# updated_at: datetime # 楽観的ロック用途 

17# user_password: str | None = Field(None) 

18# user_name: str | None = Field(None) 

19# user_role_code: str | None = Field(None) 

20 

21 

22_filters_example: dict[str, Any] = { 

23 "groupId": "abc", 

24} 

25 

26class QueryGroupRequest(BaseRequest): 

27 offset: int = Field(default=0) 

28 limit: int = Field(default=10) 

29 query: dict[str,Any] = Field( 

30 default={}, 

31 examples=[_filters_example] 

32 ) 

33 

34 @validator("query", pre=True, always=True) 

35 def validate_query(cls, query: dict[str, Any]) -> dict[str, Any]: 

36 """filtersのcaseをスネークに変換する.""" 

37 # query = query or {} 

38 return recursive_to_snake(query)