Non-consumable products updation
This commit is contained in:
@@ -235,7 +235,38 @@ def test_a_toothpaste_brand_is_not_a_chocolate():
|
||||
have been handed a health score.
|
||||
"""
|
||||
verdict = classify_edibility("General", "Colgate-Palmolive Palmolive Naturals")
|
||||
assert verdict.edibility is not Edibility.CONSUMABLE
|
||||
assert verdict.edibility is Edibility.NON_CONSUMABLE
|
||||
|
||||
|
||||
@pytest.mark.parametrize("title", [
|
||||
"Colgate-Palmolive Palmolive Naturals 350g",
|
||||
"Colgate-Palmolive Palmolive Naturals 250g",
|
||||
"Colgate-Palmolive Palmolive Naturals 100g",
|
||||
# "honey" is a food word; the brand line has to outrank it
|
||||
"Palmolive Naturals Milk & Honey 125g",
|
||||
])
|
||||
def test_a_non_food_line_in_general_is_not_scored(title):
|
||||
"""Live rows in "General" whose titles name no article at all. Asserting
|
||||
merely "not CONSUMABLE" let them through as UNKNOWN, and the write paths
|
||||
score UNKNOWN - so the verdict has to be positively NON_CONSUMABLE."""
|
||||
verdict = classify_edibility("General", title)
|
||||
assert verdict.edibility is Edibility.NON_CONSUMABLE
|
||||
assert verdict.signal == "title_brand_line"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("title", [
|
||||
"Amul Butter 500g",
|
||||
"Aachi Sambar Powder 100g",
|
||||
"Dabur Honey 500g",
|
||||
"Nestle Cerelac 300g",
|
||||
])
|
||||
def test_food_in_general_is_still_consumable(title):
|
||||
assert is_consumable("General", title) is True
|
||||
|
||||
|
||||
def test_a_real_category_outranks_the_brand_line():
|
||||
"""The brand-line list is only consulted when the category says nothing."""
|
||||
assert is_consumable("Dairy", "Pears Milk 500ml") is True
|
||||
|
||||
|
||||
def test_soapnut_is_not_a_soap():
|
||||
|
||||
@@ -120,6 +120,21 @@ def test_a_non_consumable_never_gets_a_row_written(no_writes, monkeypatch):
|
||||
)
|
||||
|
||||
|
||||
def test_a_non_food_line_filed_under_general_gets_no_row(no_writes, monkeypatch):
|
||||
"""The live shape: "General" carries no information and the title names no
|
||||
article, only the brand line. It used to classify UNKNOWN and be scored."""
|
||||
monkeypatch.setattr(nes.nutrition_data_service, "fetch_verified_nutrition",
|
||||
lambda *a, **k: pytest.fail("retrieval should not be reached"))
|
||||
|
||||
status = nes.enrich_one_product(
|
||||
"Colgate-Palmolive", "colgate_palmolive_palmolive_naturals_350g",
|
||||
"Colgate-Palmolive Palmolive Naturals 350g", "General")
|
||||
|
||||
assert status == nes.SKIPPED_NON_CONSUMABLE
|
||||
assert no_writes["facts"] == []
|
||||
assert no_writes["insights"] == []
|
||||
|
||||
|
||||
def test_skipping_is_not_reported_as_unavailable(no_writes, monkeypatch):
|
||||
"""'We did not look' and 'we looked and found nothing' are different facts,
|
||||
and the second invites a pointless retry."""
|
||||
|
||||
Reference in New Issue
Block a user