Update nutrition score retrieval using OFF v2 REST API and title cleaning
This commit is contained in:
@@ -142,3 +142,37 @@ def test_extracts_spicy() -> None:
|
||||
|
||||
def test_no_attributes_returns_empty_dict() -> None:
|
||||
assert extract_attributes("show me Parle biscuits") == {}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# New Intent Extractor & Typo Tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
from app.services.query_intent import is_count_query, extract_max_price, extract_brand_mention
|
||||
|
||||
|
||||
def test_detects_typos_in_category() -> None:
|
||||
assert detect_category_from_text("Suggest panner less than ₹100") == "Dairy"
|
||||
assert detect_category_from_text("Show me biscit options") == "Biscuits & Cookies"
|
||||
assert detect_category_from_text("chocate dark") == "Chocolates"
|
||||
|
||||
|
||||
def test_is_count_query() -> None:
|
||||
assert is_count_query("How many products are there in Cadbury?") is True
|
||||
assert is_count_query("What is the total number of items in Amul?") is True
|
||||
assert is_count_query("how many items under snacks?") is True
|
||||
assert is_count_query("Recommend Paneer under ₹150") is False
|
||||
|
||||
|
||||
def test_extract_max_price() -> None:
|
||||
assert extract_max_price("Recommend Paneer under ₹150") == 150.0
|
||||
assert extract_max_price("Suggest panner less than ₹100") == 100.0
|
||||
assert extract_max_price("biscuits below 50 rupees") == 50.0
|
||||
assert extract_max_price("what paneer do you have?") is None
|
||||
|
||||
|
||||
def test_extract_brand_mention() -> None:
|
||||
assert extract_brand_mention("How many products are there in Cadbury?") == "Cadbury"
|
||||
assert extract_brand_mention("show me Amul butter") == "Amul"
|
||||
assert extract_brand_mention("any Nestle chocolates?") == "Nestle"
|
||||
assert extract_brand_mention("suggest low sugar biscuits") is None
|
||||
|
||||
Reference in New Issue
Block a user