def setUpClass(cls): cls.recipes = load(f"{DATA_PATH}/google-recipe-example.html", python_objects=True) cls.recipe = cls.recipes[0] # input string (upload_date) is "2018-02-05T08:00:00+08:00" upload_date = cls.recipe["video"][0]["uploadDate"] cls.datetime_test = isodate.parse_datetime(upload_date)
def setUpClass(cls): cls.recipes = load('test_data/google-recipe-example.html', python_objects=True) cls.recipe = cls.recipes[0] # input string (upload_date) is "2018-02-05T08:00:00+08:00" upload_date = cls.recipe['video'][0]['uploadDate'] cls.datetime_test = isodate.parse_datetime(upload_date)
def test_recipe1(self): recipes = load('test_data/foodista-british-treacle-tart.html', migrate_old_schema=False) recipe = recipes[0] input_keys = list(recipe.keys()) # Note: 'ingredients' has been superceeded by 'recipeIngredients' in # the http://schema.org/Recipe standard for a list of ingredients. expectated_output = ['@context', 'recipeYield', '@type', 'recipeInstructions', 'ingredients', 'name'] assert lists_are_equal(expectated_output, input_keys)
def test_graph(self): recipes_old = load('test_data/crumb-lemon-tea-cakes-2018.html', python_objects=True) recipes_graph = load(Path('test_data/crumb-lemon-tea-cakes-2019.html'), python_objects=True) r_old = recipes_old[0] r_graph = recipes_graph[0] assert r_old['name'] == r_graph['name'] assert r_old['recipeCategory'] == r_graph['recipeCategory'] assert r_old['recipeCuisine'] == r_graph['recipeCuisine'] assert r_old['recipeIngredient'] == r_graph['recipeIngredient'] assert r_old['recipeYield'] == r_graph['recipeYield'] assert r_old['totalTime'] == r_graph['totalTime'] # ---- check differences ---- # the recipeInstructions in 2019 version are HowToStep format, 2018 version are in a list assert r_old['recipeInstructions'] != r_graph['recipeInstructions'] # 2019 has a datePublished, 2018 version does not r_graph['datePublished'] == datetime.date(2018, 3, 19) assert 'datePublished' not in r_old.keys()
def test_graph(self): recipes_old = load(f"{DATA_PATH}/crumb-lemon-tea-cakes-2018.html", python_objects=True) recipes_graph = load( Path(f"{DATA_PATH}/crumb-lemon-tea-cakes-2019.html"), python_objects=True) r_old = recipes_old[0] r_graph = recipes_graph[0] assert r_old["name"] == r_graph["name"] assert r_old["recipeCategory"] == r_graph["recipeCategory"] assert r_old["recipeCuisine"] == r_graph["recipeCuisine"] assert r_old["recipeIngredient"] == r_graph["recipeIngredient"] assert r_old["recipeYield"] == r_graph["recipeYield"] assert r_old["totalTime"] == r_graph["totalTime"] # ---- check differences ---- # the recipeInstructions in 2019 version are HowToStep format, 2018 version are in a list assert r_old["recipeInstructions"] != r_graph["recipeInstructions"] # 2019 has a datePublished, 2018 version does not r_graph["datePublished"] == datetime.date(2018, 3, 19) assert "datePublished" not in r_old.keys()
def test_recipe1(self): recipes = load(f"{DATA_PATH}/foodista-british-treacle-tart.html", migrate_old_schema=False) recipe = recipes[0] input_keys = list(recipe.keys()) # Note: 'ingredients' has been superceded by 'recipeIngredients' in # the http://schema.org/Recipe standard for a list of ingredients. expected_output = [ "@context", "recipeYield", "@type", "recipeInstructions", "ingredients", "name", ] assert lists_are_equal(expected_output, input_keys)
def setUpClass(cls): cls.recipes = load(f"{DATA_PATH}/foodista-british-treacle-tart.html") cls.recipe = cls.recipes[0]
def test_load(self): with self.assertRaises(SSRTypeError): load(0xFEED)
def setUpClass(cls): cls.recipes = load('test_data/foodista-british-treacle-tart.html') cls.recipe = cls.recipes[0]