Coverage for app/ddd/application/usecase/group/create_group_usecase.py: 100%

14 statements  

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

1from app.ddd.application.dto.group import CreateGroupInputDTO, CreateGroupOutputDTO 

2from app.ddd.application.usecase.group.base_group_usecase import BaseGroupUseCase 

3from app.ddd.domain.model import Group, GroupId 

4 

5 

6class CreateGroupUseCase(BaseGroupUseCase[CreateGroupInputDTO, CreateGroupOutputDTO]): 

7 def execute(self, input_dto: CreateGroupInputDTO) -> CreateGroupOutputDTO: 

8 print(input_dto) 

9 print("valid") 

10 group: Group = Group.model_validate(input_dto) 

11 print(group) 

12 with self._uow: 

13 self._uow.group_repository.insert(group) 

14 group_id = GroupId(root=group.group_id) 

15 group = self._uow.group_repository.find_by_id(group_id) # 更新情報を統合する 

16 return CreateGroupOutputDTO(group = group) # withの中でレスポンスを返す