def get(self): beer_name = self.beer_args['beer_name'] color = self.beer_args['color'] alcohol = self.beer_args['alcohol'] temperature = self.beer_args['temperature'] ingredient = self.ingredients_args['ingredient'] query_beers = BeerModel.get_beers() serialized = beers_serializer(query_beers, True) if not query_beers: return resp_empty_data_base() if beer_name: query_name = BeerModel.filter_beer_name(beer_name) error_does_not_exist(query_name, beer_name) serialized = serializer(query_name) return resp_content_successfully(serialized) if color: query_color = BeerModel.filter_beer_color(color) error_does_not_exist(query_color, color) serialized = serializer(query_color) return resp_content_successfully(serialized) if alcohol: query_alcohol = BeerModel.filter_beer_alcohol(alcohol) error_does_not_exist(query_alcohol, alcohol) serialized = serializer(query_alcohol) return resp_content_successfully(serialized) if temperature: query_temperature = BeerModel.filter_beer_temperature(temperature) error_does_not_exist(query_temperature, temperature) serialized = serializer(query_temperature) return resp_content_successfully(serialized) if ingredient: query_ingredient = IngredientsModel.filter_ingredient_name( ingredient) error_does_not_exist(query_ingredient, ingredient) serialized = add_ingredients(query_beers, serialized) response_parser = parser_beers(serialized, ingredient) return resp_content_successfully(response_parser) serialized = add_ingredients(query_beers, serialized) return resp_content_successfully(serialized)
def test_list_all_beers(self): populate_beers(2) get_all_beers = Beer.get_beers() serialized = beers_serializer(get_all_beers, True) assert len(serialized) > 0 assert serialized[0]['beer_name'] == beers_data[0]['beer_name']
def test_list_all_beers_empty(self): get_all_beers = Beer.get_beers() assert len(get_all_beers) == 0