def create_drink(
    request: CreateDrinkJsonRequest,
    drink_application_service: DrinkApplicationService = Depends(
        Provide[Container.drink_application_service]),
) -> Optional[JSONResponse]:
    input_dto = CreateDrinkInputDto(
        drink_name=request.drink_name,
        drink_image_url=request.drink_image_url,
        drink_type=request.drink_type,
    )
    output_dto = drink_application_service.create_drink(input_dto=input_dto)
    if not output_dto.status:
        return FailedJsonResponse.build_by_output_dto(output_dto)
def test_create_drink_fail(
    drink_repository_mock,
    drink_id,
    drink_name,
    drink_image_url,
    drink_type,
):
    drink_repository_mock.add.side_effect = ResourceAlreadyExistError()
    drink_application_service = DrinkApplicationService(
        drink_repository=drink_repository_mock)
    input_dto = CreateDrinkInputDto(
        drink_id=str(drink_id),
        drink_name=drink_name,
        drink_image_url=drink_image_url,
        drink_type=drink_type.value,
    )

    actual = drink_application_service.create_drink(input_dto)
    expected = FailedOutputDto(type="Resource Conflict Error", message="")
    assert actual == expected
def test_create_drink_success(
    drink_repository_mock,
    drink_id,
    drink_name,
    drink_image_url,
    drink_type,
):
    drink_repository_mock.add.return_value = None
    drink_application_service = DrinkApplicationService(
        drink_repository=drink_repository_mock)
    input_dto = CreateDrinkInputDto(
        drink_id=str(drink_id),
        drink_name=drink_name,
        drink_image_url=drink_image_url,
        drink_type=drink_type.value,
    )

    actual = drink_application_service.create_drink(input_dto)
    expected = CreateDrinkOutputDto()
    assert actual == expected