예제 #1
0
 def test_single_heading(self):
     recipe = Recipe(raw_ingredients="|Batter\nSugar\nButter\nMilk")
     
     expected_groupings = [
         {"heading": "Batter", "ingredients": ["Sugar", "Butter", "Milk"]},
         ]
     found_groupings = _group_ingredients_by_heading(recipe.ingredients)
     self.assertEqual(expected_groupings, found_groupings)
예제 #2
0
 def test_mixture(self):
     recipe = Recipe(raw_ingredients="Sugar\nButter\nMilk\n|Other\nWater")
     
     expected_groupings = [
         {"heading": None, "ingredients": ["Sugar", "Butter", "Milk"]},
         {"heading": "Other", "ingredients": ["Water"]},
         ]
     found_groupings = _group_ingredients_by_heading(recipe.ingredients)
     self.assertEqual(expected_groupings, found_groupings)
예제 #3
0
 def test_empty_headings(self):
     recipe = Recipe(raw_ingredients="|One\n|Two")
     
     expected_groupings = [
         {"heading": "One", "ingredients": []},
         {"heading": "Two", "ingredients": []},
         ]
     found_groupings = _group_ingredients_by_heading(recipe.ingredients)
     self.assertEqual(expected_groupings, found_groupings)