Coverage for app/ddd/application/usecase/user/create_user_report_usecase.py: 100%
11 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
1from app.ddd.application.dto.user import (
2 CreateUserReportInputDTO,
3 CreateUserReportOutputDTO,
4)
5from app.ddd.application.usecase.user.base_user_usecase import BaseUserUseCase
6from app.ddd.domain.model import UserId
9class CreateUserReportUseCase(BaseUserUseCase[CreateUserReportInputDTO, CreateUserReportOutputDTO]):
10 def execute(self, input_dto: CreateUserReportInputDTO) -> CreateUserReportOutputDTO:
11 user_id = UserId(root=input_dto.user_id)
12 user = self._uow.user_repository.find_by_id(user_id)
13 user_report = user.add_report(**input_dto.model_dump())
14 with self._uow:
15 self._uow.user_repository.insert_user_report(user)
16 return CreateUserReportOutputDTO(
17 user_report_id = user_report.user_report_id
18 )