def test_delete_drink_wish_fail(
    drink_repository_mock,
    drink_id,
    drink_name,
    drink_image_url,
    drink_type,
):
    drink_repository_mock.find_by_drink_id.side_effect = ResourceNotFoundError(
    )
    drink_repository_mock.update.return_value = None
    drink_application_service = DrinkApplicationService(
        drink_repository=drink_repository_mock)

    input_dto = DeleteDrinkWishInputDto(drink_id=str(drink_id))
    actual = drink_application_service.delete_drink_wish(input_dto)
    expected = FailedOutputDto(type="Resource Not Found Error", message="")
    assert actual == expected

    drink_repository_mock.find_by_drink_id.return_value = None
    drink_repository_mock.update.side_effect = ResourceNotFoundError()
    drink_application_service = DrinkApplicationService(
        drink_repository=drink_repository_mock)

    input_dto = DeleteDrinkWishInputDto(drink_id=str(drink_id))
    actual = drink_application_service.delete_drink_wish(input_dto)
    expected = FailedOutputDto(type="Resource Not Found Error", message="")
    assert actual == expected
def test_delete_drink_wish_success(
    drink_repository_mock,
    drink_id,
    drink_name,
    drink_image_url,
    drink_type,
):
    drink_repository_mock.find_by_drink_id.return_value = Drink(
        id=drink_id,
        name=drink_name,
        image_url=drink_image_url,
        type=drink_type)
    drink_repository_mock.update.return_value = None
    drink_application_service = DrinkApplicationService(
        drink_repository=drink_repository_mock)

    input_dto = DeleteDrinkWishInputDto(drink_id=str(drink_id))
    actual = drink_application_service.delete_drink_wish(input_dto)
    expected = DeleteDrinkWishOutputDto()
    assert actual == expected
    def delete_wish(
        self,
        input_dto: DeleteWishInputDto,
        drink_application_service: DrinkApplicationService,
    ) -> Union[DeleteWishOutputDto, FailedOutputDto]:
        try:
            wish = self._wish_repository.delete_by_wish_id(
                WishId.from_str(input_dto.wish_id))

            delete_drink_wish_input_dto = DeleteDrinkWishInputDto(
                drink_id=str(wish.drink_id))
            delete_drink_wish_output_dto = drink_application_service.delete_drink_wish(
                input_dto=delete_drink_wish_input_dto)

            if not delete_drink_wish_output_dto.status:
                return delete_drink_wish_output_dto
            return DeleteWishOutputDto()
        except ResourceNotFoundError as e:
            return FailedOutputDto.build_resource_not_found_error(
                message=str(e))
        except Exception as e:
            return FailedOutputDto.build_system_error(message=str(e))