added ingrediet_to_parts tests
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
e207c359ed
commit
209597432d
|
|
@ -121,7 +121,7 @@ def parse_recipe_name(
|
||||||
|
|
||||||
return recipe
|
return recipe
|
||||||
|
|
||||||
def parse_ingredient(
|
def ingredient_to_parts(
|
||||||
ingredient: db.Ingredient
|
ingredient: db.Ingredient
|
||||||
) -> db.RecipeIngredientParts:
|
) -> db.RecipeIngredientParts:
|
||||||
parts = parse_ingredient(ingredient.text)
|
parts = parse_ingredient(ingredient.text)
|
||||||
|
|
@ -153,7 +153,7 @@ def parse_recipe(session, recipe, site):
|
||||||
session.add(ingredient)
|
session.add(ingredient)
|
||||||
session.flush()
|
session.flush()
|
||||||
|
|
||||||
parts = parse_ingredient(ingredient)
|
parts = ingredient_to_parts(ingredient)
|
||||||
if parts:
|
if parts:
|
||||||
session.add(parts)
|
session.add(parts)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ def mock_site():
|
||||||
base_url="example-site/mock-site",
|
base_url="example-site/mock-site",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# TODO: should probably load HTML from file
|
# TODO: should probably load HTML from file
|
||||||
@fixture
|
@fixture
|
||||||
def mock_page():
|
def mock_page():
|
||||||
|
|
@ -39,6 +38,10 @@ def mock_recipe():
|
||||||
return Recipe(name="test_recipe", identifier="mock_1")
|
return Recipe(name="test_recipe", identifier="mock_1")
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def mock_ingredient():
|
||||||
|
return RecipeIngredient(text="1 ounce water")
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
def mock_url():
|
def mock_url():
|
||||||
return "example-site/mock-site"
|
return "example-site/mock-site"
|
||||||
|
|
@ -76,5 +79,12 @@ def test_parse_recipe_name(mock_site, mock_page, mock_recipe, mock_url):
|
||||||
mock_url,
|
mock_url,
|
||||||
)
|
)
|
||||||
assert mock_recipe.name == expected_name
|
assert mock_recipe.name == expected_name
|
||||||
# assert False
|
|
||||||
|
|
||||||
|
|
||||||
|
def test_ingredient_to_parts(mock_ingredient):
|
||||||
|
parts = scrape.ingredient_to_parts(mock_ingredient)
|
||||||
|
assert parts.quantity == "1"
|
||||||
|
assert parts.unit == "ounce"
|
||||||
|
assert parts.instruction == ""
|
||||||
|
assert parts.ingredient == "water"
|
||||||
|
assert parts.supplement == None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue