Ejemplo n.º 1
0
 def test_split_and_ingredients(self):
     assert utils.split_and_ingredients(['salt and pepper', 'water'
                                         ]) == ['salt', 'pepper', 'water']
     assert utils.split_and_ingredients(['grand banana'
                                         ]) == ['grand banana']
     assert utils.split_and_ingredients([
         '2 and a half glasses of milk'
     ]) == ['2 and a half glasses of milk']
     assert utils.split_and_ingredients(
         ['2 and 1/2 glasses of milk']) == ['2 and 1/2 glasses of milk']
     assert utils.split_and_ingredients(["1 egg,,,,"]) == ["1 egg,,,,"]
Ejemplo n.º 2
0
 def test_split_and_ingredients(self):
     assert split_and_ingredients(["salt and pepper", "water"]) == [
         "salt",
         "pepper",
         "water",
     ]
     assert split_and_ingredients(["grand banana"]) == ["grand banana"]
     assert split_and_ingredients(["2 and a half glasses of milk"
                                   ]) == ["2 and a half glasses of milk"]
     assert split_and_ingredients(["2 and 1/2 glasses of milk"
                                   ]) == ["2 and 1/2 glasses of milk"]
     assert split_and_ingredients(["1 egg,,,,"]) == ["1 egg,,,,"]
Ejemplo n.º 3
0
    def __init__(
        self, ingredient_list: list, parser: Callable[[str], dict] = parse_ingredient
    ):
        """
        :ingredient_list - list of ingredients
        :parser - parser which handles user input (ingredient name)
        """
        self.raw = ingredient_list
        self.all = []
        self.bad = []

        ingredient_list = split_and_ingredients(ingredient_list)
        for ing in ingredient_list:
            try:
                self.all.append(Ingredient(ing, parser=parser))
            except IngredientError:
                self.bad.append(ing)
            except ParseIngredientError:
                self.bad.append(ing)
Ejemplo n.º 4
0
    def __init__(
        self,
        ingredient_list: list,
        parser: Callable[[str], dict] = search.parse_ingredient,
    ):
        """
        :ingredient_list - list of ingredients
        :parser - parser which handles user input (ingredient name)
        """
        self.raw = ingredient_list
        self.all = []
        self.bad = []

        # Index of __next__
        self._n = 0

        ingredient_list = utils.split_and_ingredients(ingredient_list)
        for ing in ingredient_list:
            try:
                self.all.append(Ingredient(ing, parser=parser))
            except IngredientError:
                self.bad.append(ing)
            except search.ParseIngredientError:
                self.bad.append(ing)