mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 21:45:25 +02:00
fix(deps): update dependency ingredient-parser-nlp to v2 (#5137)
This commit is contained in:
parent
61ae6b3e32
commit
cfba2fff7e
4 changed files with 148 additions and 16 deletions
|
@ -8,7 +8,7 @@ from tests.utils.fixture_schemas import TestUser
|
|||
|
||||
nlp_test_ingredients = [
|
||||
TestIngredient("½ cup all-purpose flour", 0.5, "cup", "all-purpose flour", ""),
|
||||
TestIngredient("1 ½ teaspoons ground black pepper", 1.5, "teaspoon", "ground black pepper", ""),
|
||||
TestIngredient("1 ½ teaspoons ground black pepper", 1.5, "teaspoon", "black pepper", "ground"),
|
||||
TestIngredient("⅔ cup unsweetened flaked coconut", 0.667, "cup", "unsweetened flaked coconut", ""),
|
||||
TestIngredient("⅓ cup panko bread crumbs", 0.333, "cup", "panko bread crumbs", ""),
|
||||
TestIngredient("1/8 cup all-purpose flour", 0.125, "cup", "all-purpose flour", ""),
|
||||
|
@ -23,14 +23,21 @@ nlp_test_ingredients = [
|
|||
),
|
||||
TestIngredient("2 tablespoons (30ml) vegetable oil ", 2, "tablespoon", "vegetable oil", ""),
|
||||
TestIngredient("2 teaspoons salt (to taste) ", 2, "teaspoon", "salt", "to taste"),
|
||||
TestIngredient("2 cups chicken broth or beef broth ", 2, "cup", "chicken broth", ""),
|
||||
TestIngredient("1/2 cup", 0.5, "cup", "", ""),
|
||||
]
|
||||
|
||||
|
||||
def assert_ingredient(api_response: dict, test_ingredient: TestIngredient):
|
||||
assert api_response["ingredient"]["quantity"] == pytest.approx(test_ingredient.quantity)
|
||||
assert api_response["ingredient"]["unit"]["name"] == test_ingredient.unit
|
||||
assert api_response["ingredient"]["food"]["name"] == test_ingredient.food
|
||||
assert api_response["ingredient"]["note"] == test_ingredient.comments
|
||||
response_quantity = api_response["ingredient"]["quantity"]
|
||||
response_unit = api_response["ingredient"]["unit"]["name"] if api_response["ingredient"]["unit"] else ""
|
||||
response_food = api_response["ingredient"]["food"]["name"] if api_response["ingredient"]["food"] else ""
|
||||
response_note = api_response["ingredient"]["note"]
|
||||
|
||||
assert response_quantity == pytest.approx(test_ingredient.quantity)
|
||||
assert response_unit == test_ingredient.unit
|
||||
assert response_food == test_ingredient.food
|
||||
assert response_note == test_ingredient.comments
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_ingredient", nlp_test_ingredients)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue