increassed code coverage
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Andrei Stoica 2023-05-18 23:52:20 -04:00
parent 209597432d
commit cf05777f2c
2 changed files with 17 additions and 3 deletions

View File

@ -110,7 +110,7 @@ def parse_recipe_name(
url: str = None,
) -> db.Recipe:
if not url:
url = {"site": site, "recipe": recipe}
url = {"site": site.base_url, "recipe": recipe.identifier}
name_candidates = page.find_all(class_=site.name_class)
if len(name_candidates) == 0:
raise Exception(f"Could not extract recipe name: {url}")

View File

@ -68,7 +68,7 @@ def test_ingredient_regex():
)
def test_parse_recipe_name(mock_site, mock_page, mock_recipe, mock_url):
def test_parse_recipe_name(mock_site, mock_page, mock_recipe, mock_url, mock_blank_page,):
expected_name = mock_recipe.name
mock_recipe.name = None
@ -76,10 +76,23 @@ def test_parse_recipe_name(mock_site, mock_page, mock_recipe, mock_url):
mock_site,
mock_page,
mock_recipe,
mock_url,
)
assert mock_recipe.name == expected_name
ex = None
try:
mock_recipe = scrape.parse_recipe_name(
mock_site,
mock_blank_page,
mock_recipe,
)
except Exception as e:
ex = e
url = {"site": mock_site.base_url, "recipe": mock_recipe.identifier}
assert str(e) == f"Could not extract recipe name: {url}"
assert ex
def test_ingredient_to_parts(mock_ingredient):
parts = scrape.ingredient_to_parts(mock_ingredient)
@ -88,3 +101,4 @@ def test_ingredient_to_parts(mock_ingredient):
assert parts.instruction == ""
assert parts.ingredient == "water"
assert parts.supplement == None