Example #1
0
 def test_when_no_ingredients(self):
     lines = [
         '---------- Recipe via Meal-Master (tm) v8.05',
         ' ',
         '      Title: Potato Casserole',
         ' Categories: Casserole, Potato',
         '      Yield: 8 Servings',
         ' ',
         '  Thaw potatoes about 30 min., then mix all ingredients in a large bowl.',
         '  Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         '  ',
         '  Recipe by: From recipe files of Martha',
         ' ',
         '-----',
     ]
     expected_title = 'Potato Casserole'
     expected_categories = ['Casserole', 'Potato']
     expected_yield = ''
     expected_servings = 8
     expected_ingredients = []
     expected_directions = [
         'Thaw potatoes about 30 min., then mix all ingredients in a large bowl. Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         'Recipe by: From recipe files of Martha',
     ]
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #2
0
 def test_when_no_ingredients(self):
     lines = [
         '---------- Recipe via Meal-Master (tm) v8.05',
         ' ',
         '      Title: Potato Casserole',
         ' Categories: Casserole, Potato',
         '      Yield: 8 Servings',
         ' ',
         '  Thaw potatoes about 30 min., then mix all ingredients in a large bowl.',
         '  Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         '  ',
         '  Recipe by: From recipe files of Martha',
         ' ',
         '-----',
         ]
     expected_title = 'Potato Casserole'
     expected_categories = ['Casserole', 'Potato']
     expected_yield = ''
     expected_servings = 8
     expected_ingredients = []
     expected_directions = [
         'Thaw potatoes about 30 min., then mix all ingredients in a large bowl. Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         'Recipe by: From recipe files of Martha',
     ]
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #3
0
 def test_when_extra_empty_lines(self):
     lines = [
         ' ',
         '---------- Recipe via Meal-Master (tm) v8.05',
         ' ',
         '      Title: Potato Casserole',
         ' ',
         ' ',
         ' ',
         ' Categories: Casserole, Potato',
         ' ',
         ' ',
         '      Yield: 8 Servings',
         ' ',
         ' ',
         '      2 lb Frozen hash brown potatoes',
         '      1 c  Onions; diced',
         '      1 cn Cream of chicken soup',
         '     16 oz Sour cream',
         ' ',
         '    1/2 c  Melted margarine',
         '      8 oz Grated sharp cheese',
         '           Salt and pepper to taste',
         '',
         '  Thaw potatoes about 30 min., then mix all ingredients in a large bowl.',
         '  Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         '  ',
         ' ',
         ' ',
         '  Recipe by: From recipe files of Martha',
         ' ',
         '-----',
         ' ',
         ]
     expected_title = 'Potato Casserole'
     expected_categories = ['Casserole', 'Potato']
     expected_yield = ''
     expected_servings = 8
     expected_ingredients = [
         '{2} {lb} {Frozen hash brown potatoes}',
         '{1} {c} {Onions; diced}',
         '{1} {cn} {Cream of chicken soup}',
         '{16} {oz} {Sour cream}',
         '{1/2} {c} {Melted margarine}',
         '{8} {oz} {Grated sharp cheese}',
         '{} {} {Salt and pepper to taste}',
         ]
     expected_directions = [
         'Thaw potatoes about 30 min., then mix all ingredients in a large bowl. Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         'Recipe by: From recipe files of Martha',
     ]
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #4
0
 def test_when_extra_empty_lines(self):
     lines = [
         ' ',
         '---------- Recipe via Meal-Master (tm) v8.05',
         ' ',
         '      Title: Potato Casserole',
         ' ',
         ' ',
         ' ',
         ' Categories: Casserole, Potato',
         ' ',
         ' ',
         '      Yield: 8 Servings',
         ' ',
         ' ',
         '      2 lb Frozen hash brown potatoes',
         '      1 c  Onions; diced',
         '      1 cn Cream of chicken soup',
         '     16 oz Sour cream',
         ' ',
         '    1/2 c  Melted margarine',
         '      8 oz Grated sharp cheese',
         '           Salt and pepper to taste',
         '',
         '  Thaw potatoes about 30 min., then mix all ingredients in a large bowl.',
         '  Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         '  ',
         ' ',
         ' ',
         '  Recipe by: From recipe files of Martha',
         ' ',
         '-----',
         ' ',
     ]
     expected_title = 'Potato Casserole'
     expected_categories = ['Casserole', 'Potato']
     expected_yield = ''
     expected_servings = 8
     expected_ingredients = [
         '{2} {lb} {Frozen hash brown potatoes}',
         '{1} {c} {Onions; diced}',
         '{1} {cn} {Cream of chicken soup}',
         '{16} {oz} {Sour cream}',
         '{1/2} {c} {Melted margarine}',
         '{8} {oz} {Grated sharp cheese}',
         '{} {} {Salt and pepper to taste}',
     ]
     expected_directions = [
         'Thaw potatoes about 30 min., then mix all ingredients in a large bowl. Place in a 9 X 13 baking dish. Bake at 350 for one hour. Serves 8',
         'Recipe by: From recipe files of Martha',
     ]
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #5
0
 def test_when_empty(self):
     lines = []
     expected_title = ''
     expected_categories = []
     expected_yield = ''
     expected_servings = 0
     expected_ingredients = []
     expected_directions = []
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #6
0
 def test_when_empty(self):
     lines = []
     expected_title = ''
     expected_categories = []
     expected_yield = ''
     expected_servings = 0
     expected_ingredients = []
     expected_directions = []
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #7
0
 def test_when_only_header(self):
     lines = [
         '---------- Recipe via Meal-Master (tm) v8.05',
         ]
     expected_title = ''
     expected_categories = []
     expected_yield = ''
     expected_servings = 0
     expected_ingredients = []
     expected_directions = []
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #8
0
 def test_when_only_header(self):
     lines = [
         '---------- Recipe via Meal-Master (tm) v8.05',
     ]
     expected_title = ''
     expected_categories = []
     expected_yield = ''
     expected_servings = 0
     expected_ingredients = []
     expected_directions = []
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #9
0
 def test_when_two_column(self):
     lines = [
         'MMMMM----- Recipe via Meal-Master (tm) v8.02',
         ' ',
         '      Title: Potato-Sorrel Soup',
         ' Categories: Soup/stew, Vegetarian',
         '      Yield: 6 servings',
         ' ',
         '      4 tb Butter                            1/2 ts Salt (to taste)',
         '      7 c  Water                           1 1/2 lb Red potatoes; quartered',
         '      3 md Leeks; the white parts only              - lengthwise & thinly sliced',
         '           - chopped or cut                         Freshly ground pepper',
         '           - into 1/4-inch rounds                   Creme fraiche',
         'MMMMM--------------------------HEADING-------------------------------',
         '      6 c  Loosely packed sorrel leaves        1 tb Chives',
         '           -the stems removed and                   - thinly sliced or snipped',
         '           - leaves roughly chopped       ',
         'MMMMM--------------------------HEADING-------------------------------',
         ' ',
         '  This is a rather rustic soup. For a more refined version, pass it',
         '  through a food mill before serving.',
         ' ',
         'MMMMM'
         ]
     expected_title = 'Potato-Sorrel Soup'
     expected_categories = ['Soup/stew', 'Vegetarian']
     expected_yield = ''
     expected_servings = 6
     expected_ingredients = [
         '{4} {tb} {Butter}',
         '{7} {c} {Water}',
         '{3} {md} {Leeks; the white parts only chopped or cut into 1/4-inch rounds}',
         '{1/2} {ts} {Salt (to taste)}',
         '{1 1/2} {lb} {Red potatoes; quartered lengthwise & thinly sliced}',
         '{} {} {Freshly ground pepper}',
         '{} {} {Creme fraiche}',
         '----- HEADING -----',
         '{6} {c} {Loosely packed sorrel leaves the stems removed and leaves roughly chopped}',
         '{1} {tb} {Chives thinly sliced or snipped}',
         '----- HEADING -----',
         ]
     expected_directions = [
         'This is a rather rustic soup. For a more refined version, pass it through a food mill before serving.',
     ]
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #10
0
 def test_when_two_column(self):
     lines = [
         'MMMMM----- Recipe via Meal-Master (tm) v8.02', ' ',
         '      Title: Potato-Sorrel Soup',
         ' Categories: Soup/stew, Vegetarian', '      Yield: 6 servings',
         ' ',
         '      4 tb Butter                            1/2 ts Salt (to taste)',
         '      7 c  Water                           1 1/2 lb Red potatoes; quartered',
         '      3 md Leeks; the white parts only              - lengthwise & thinly sliced',
         '           - chopped or cut                         Freshly ground pepper',
         '           - into 1/4-inch rounds                   Creme fraiche',
         'MMMMM--------------------------HEADING-------------------------------',
         '      6 c  Loosely packed sorrel leaves        1 tb Chives',
         '           -the stems removed and                   - thinly sliced or snipped',
         '           - leaves roughly chopped       ',
         'MMMMM--------------------------HEADING-------------------------------',
         ' ',
         '  This is a rather rustic soup. For a more refined version, pass it',
         '  through a food mill before serving.', ' ', 'MMMMM'
     ]
     expected_title = 'Potato-Sorrel Soup'
     expected_categories = ['Soup/stew', 'Vegetarian']
     expected_yield = ''
     expected_servings = 6
     expected_ingredients = [
         '{4} {tb} {Butter}',
         '{7} {c} {Water}',
         '{3} {md} {Leeks; the white parts only chopped or cut into 1/4-inch rounds}',
         '{1/2} {ts} {Salt (to taste)}',
         '{1 1/2} {lb} {Red potatoes; quartered lengthwise & thinly sliced}',
         '{} {} {Freshly ground pepper}',
         '{} {} {Creme fraiche}',
         '----- HEADING -----',
         '{6} {c} {Loosely packed sorrel leaves the stems removed and leaves roughly chopped}',
         '{1} {tb} {Chives thinly sliced or snipped}',
         '----- HEADING -----',
     ]
     expected_directions = [
         'This is a rather rustic soup. For a more refined version, pass it through a food mill before serving.',
     ]
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #11
0
 def test_when_no_ingredients_or_directions(self):
     lines = [
         '---------- Recipe via Meal-Master (tm) v8.05',
         ' ',
         '      Title: Potato Casserole',
         ' Categories: Casserole, Potato',
         '      Yield: 8 Servings',
         ' ',
         '-----',
         ]
     expected_title = 'Potato Casserole'
     expected_categories = ['Casserole', 'Potato']
     expected_yield = ''
     expected_servings = 8
     expected_ingredients = []
     expected_directions = []
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)
Example #12
0
 def test_when_no_ingredients_or_directions(self):
     lines = [
         '---------- Recipe via Meal-Master (tm) v8.05',
         ' ',
         '      Title: Potato Casserole',
         ' Categories: Casserole, Potato',
         '      Yield: 8 Servings',
         ' ',
         '-----',
     ]
     expected_title = 'Potato Casserole'
     expected_categories = ['Casserole', 'Potato']
     expected_yield = ''
     expected_servings = 8
     expected_ingredients = []
     expected_directions = []
     actual = mmf.parse_recipe(lines)
     self.assert_equal(actual, expected_title, expected_categories,
                       expected_yield, expected_servings,
                       expected_ingredients, expected_directions)