Coverage for app/ddd/presentation/endpoint/group/delete_group.py: 100%
15 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 fastapi import Depends, Path
2from sqlmodel import Session
4from app.ddd.application.dto.group import DeleteGroupInputDTO, DeleteGroupOutputDTO
5from app.ddd.application.usecase.group import DeleteGroupUseCase
6from app.ddd.infrastructure.database.db import get_session
7from app.ddd.infrastructure.uow import GroupUnitOfWorkImpl
8from app.ddd.presentation.endpoint.group.router import router
9from app.ddd.presentation.schema.group import DeleteGroupResponse
12def __usecase(session: Session = Depends(get_session)) -> DeleteGroupUseCase:
13 return DeleteGroupUseCase(uow=GroupUnitOfWorkImpl(session))
15@router.delete(
16 path="/groups/{groupId}",
17 response_model=DeleteGroupResponse,
18 responses={
19 # TODO(nonomura): Error 1:n ErrorResponse.errors
20 # status.HTTP_404_NOT_FOUND: GroupNotFoundError(group_id='dammy').response(),
21 # status.HTTP_404_NOT_FOUND: {
22 # "content": {
23 # "application/json": {
24 # "example": {
25 # "detail": [
26 # GroupNotFoundError(group_id="dammy").camel_detail(),
27 # ]
28 # }
29 # }
30 # },
31 # }
32 },
34)
35def delete_group(
36 group_id: str = Path(..., alias="groupId"),
37 usecase: DeleteGroupUseCase = Depends(__usecase),
38) -> DeleteGroupResponse:
39 """Groupを削除する."""
40 input_dto: DeleteGroupInputDTO = DeleteGroupInputDTO(group_id=group_id)
41 dto: DeleteGroupOutputDTO = usecase.execute(input_dto)
42 return DeleteGroupResponse.model_validate(dto)