def test_find_drink_success( client, app, 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_application_service = DrinkApplicationService( drink_repository=drink_repository_mock) input_dto = FindDrinkInputDto(drink_id=str(drink_id)) actual = drink_application_service.find_drink(input_dto) expected = FindDrinkOutputDto( drink_id=str(drink_id), drink_name=drink_name, drink_image_url=drink_image_url, drink_type=drink_type.value, avg_rating=float(DrinkRating()), num_of_reviews=0, num_of_wish=0, ) assert actual == expected
def test_find_drink_fail( client, app, drink_repository_mock, drink_id, drink_name, drink_image_url, drink_type, ): drink_repository_mock.find_by_drink_id.side_effect = ResourceNotFoundError( ) drink_application_service = DrinkApplicationService( drink_repository=drink_repository_mock) input_dto = FindDrinkInputDto(drink_id=str(drink_id)) actual = drink_application_service.find_drink(input_dto) expected = FailedOutputDto(type="Resource Not Found Error", message="") assert actual == expected