def test_fetch_title(): expected = "しゅんぎくと菊の花のおひたし" test_data = './test_data/10100006.json' data = load_json(test_data) result = Dish.fetch_title(data) assert result == expected
def test_fetch_ingredients(): expected = [ OrderedDict([("description", "しゅんぎく"), ("quantityText", "200g"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "菊の花(食用)"), ("quantityText", "50g"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "酢"), ("quantityText", "大さじ1"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "しょうゆ"), ("quantityText", "大さじ1/2"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "だし"), ("quantityText", "大さじ1"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), ] test_data = './test_data/10100006.json' data = load_json(test_data) dish = Dish(data) # instance = dish.build() result = dish.fetch_ingredients(data) assert result == expected
def test_fetch_instruction(): expected = [ { "steps": 1, "description": "しゅんぎくは、茎のかたいところはとり除き、洗います。", }, { "steps": 2, "description": "熱湯で30秒ほどゆで、すぐ水にとってさまし、手早く水気をしぼって、4cm長さに切ります。", }, { "steps": 3, "description": "菊の花は、花びらをむしります。", }, { "steps": 4, "description": "水カップ3をわかして酢を入れ、菊の花びらを約20秒ゆでます。水にとってさらし、水気をしっかりしぼります。", }, { "steps": 5, "description": "しょうゆとだしを合わせます(割りじょうゆ)。", }, { "steps": 6, "description": "しゅんぎくと菊の花をほぐして混ぜ、割りじょうゆをかけます。", }, ] test_data = './test_data/10100006.json' data = load_json(test_data) result = Instruction.fetch_instruction(data) assert result == expected
def load_test_data(): test_data = './test_data/10100006.json' data = load_json(test_data) instance = Dish(data) dish = instance.build() return dish
def test_fetch_units(): expected = "4人分" test_data = './test_data/10100006.json' data = load_json(test_data) result = Dish.fetch_unit(data) assert result == expected
def test_inject_dict(): expected = [{ "description": "枝豆(さやつき)", "quantityText": "150g(正味75g)" }, { "description": "枝豆(さやつき)300g(正味150g)", "quantityText": None }, { "items": [{ "description": "砂糖", "quantityText": "大さじ1/2弱" }, { "description": "塩", "quantityText": "小さじ1/12" }, { "description": "だし", "quantityText": "大さじ1" }] }, { "description": "干ししいたけ", "quantityText": "1/2枚" }, { "description": "にんじん", "quantityText": "15g" }, { "description": "こんにゃく(白)", "quantityText": "1/10枚" }, { "description": "A", "quantityText": None }, { "items": [{ "description": "だし", "quantityText": "カップ1/6" }, { "description": "酒", "quantityText": "大さじ1/4" }, { "description": "しょうゆ", "quantityText": "小さじ1/2" }, { "description": "塩", "quantityText": "少々" }] }] test_file = './test_data/10100002.json' data = load_json(test_file) dish_builder = Dish(data) dish = dish_builder.build() norm = normalize_quantity(dish, 4) params = multiply_quantity(dish, norm, 2) multi = Multiplier(dish, params) result = multi.build() print('result') print(result) assert result == expected
def test_build_dishes(): expected = { "title": "しゅんぎくと菊の花のおひたし", "cookingTool": "", "nutrition": [ { "note": "" }, { "salt": 0.0 }, { "protein": 0.0 }, { "calory": 15 }, { "lipid": 0.0 }, { "carbohydrate": 0.0 }, ], "ingredients": [ OrderedDict([("description", "しゅんぎく"), ("quantityText", "200g"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "菊の花(食用)"), ("quantityText", "50g"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "酢"), ("quantityText", "大さじ1"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "しょうゆ"), ("quantityText", "大さじ1/2"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), OrderedDict([("description", "だし"), ("quantityText", "大さじ1"), ("ingredientId", 0), ("classificationId", 0), ("intermediateId", 0)]), ], } test_data = './test_data/10100006.json' data = load_json(test_data) title = Dish.fetch_title(data) ingredients = Dish.fetch_ingredients(data) result = Dish.build_dishes(title, ingredients) assert result == expected
def test_load_json(): expected = { "a": "あ", "b": "い", "c": { "d": "う", "e": "え", }, } test_data = './test_data/sample_test_json.json' result = load_json(test_data) assert result == expected