|
@@ -0,0 +1,58 @@
|
|
|
|
+#
|
|
|
|
+# Copyright (c) Daniel Sheffield 2023
|
|
|
|
+#
|
|
|
|
+# All rights reserved
|
|
|
|
+#
|
|
|
|
+# THIS SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY
|
|
|
|
+from pytest import fixture
|
|
|
|
+from app.parse_recipe import parse_recipe
|
|
|
|
+from app.data.QueryManager import QueryManager
|
|
|
|
+from app.rest import ALL_UNITS
|
|
|
|
+
|
|
|
|
+@fixture
|
|
|
|
+def blank_recipe():
|
|
|
|
+ with open('recipes/Blank.yaml') as fh:
|
|
|
|
+ yield fh
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+@fixture
|
|
|
|
+def matzo_recipe():
|
|
|
|
+ with open('recipes/Matzo.yaml') as fh:
|
|
|
|
+ yield fh
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+@fixture
|
|
|
|
+def units():
|
|
|
|
+ return ALL_UNITS | set([
|
|
|
|
+ 'Cup (metric)',
|
|
|
|
+ 'tsp (metric)',
|
|
|
|
+ ])
|
|
|
|
+
|
|
|
|
+@fixture
|
|
|
|
+def query_manager(units):
|
|
|
|
+ qm = QueryManager(None, None)
|
|
|
|
+ qm.unique_suggestions = lambda *_1, **_2: units
|
|
|
|
+ return qm
|
|
|
|
+
|
|
|
|
+def test_parse_blank_recipe(query_manager, blank_recipe):
|
|
|
|
+ assert parse_recipe(blank_recipe, query_manager) == {
|
|
|
|
+ 'ingredients': [],
|
|
|
|
+ 'feeds': 1,
|
|
|
|
+ 'instructions': '',
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+def test_parse_matzo_recipe(query_manager, matzo_recipe):
|
|
|
|
+ assert parse_recipe(matzo_recipe, query_manager) == {
|
|
|
|
+ 'ingredients': [
|
|
|
|
+ ['Wheat Berries', '241', 'g'],
|
|
|
|
+ ['Olive Oil', '0.25', 'Cup (metric)'],
|
|
|
|
+ ['Salt', '1', 'tsp (metric)']],
|
|
|
|
+ 'feeds': 16,
|
|
|
|
+ 'instructions': """Soak **Wheat Berries** and sprout. Dehydrate in oven. Grind into flour.
|
|
|
|
+Preheat oven to 200C.
|
|
|
|
+Combine 150 grams of warm water with **Salt**.
|
|
|
|
+Mix **Olive Oil** and flour and water into a dough.
|
|
|
|
+Roll out into an oval. Score.
|
|
|
|
+Bake at 200C for 5 minutes, flip and repeat."""
|
|
|
|
+ }
|
|
|
|
+
|