File size: 2,592 Bytes
1cd137c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Tests for the classify_product orchestrator."""
from __future__ import annotations

from reference_db.classification.classifier import classify_product


class TestClassifierIntegration:
    """End-to-end tests for classify_product."""

    def test_baby_greens_is_food(self):
        """Baby Greens should be classified as food."""
        result = classify_product("Baby Greens Mixed 142 g")
        assert result.domain == "food"

    def test_without_antibiotics_is_food(self):
        """'Without Antibiotics' should not negate food classification."""
        result = classify_product("Compliments Raised Without Antibiotics Chicken Wings Split")
        assert result.domain == "food"

    def test_antibiotic_free_is_food(self):
        """'Antibiotic Free' should not negate food classification."""
        result = classify_product("Antibiotic Free Chicken Wings")
        assert result.domain == "food"

    def test_free_range_is_food(self):
        """'Free Range' should not negate food classification."""
        result = classify_product("Free Range Chicken Breast")
        assert result.domain == "food"

    def test_zero_sugar_is_food(self):
        """'Zero Sugar' should not negate food classification."""
        result = classify_product("Zero Sugar Ginger Ale 2 L (bottle)")
        assert result.domain == "food"

    def test_fabric_softener_is_non_food(self):
        """Fabric softener should be classified as non_food."""
        result = classify_product("Fragrance Free Fabric Softener Sheets 120 Sheets")
        assert result.domain == "non_food"

    def test_chicken_wings_is_food(self):
        """Simple food product should classify as food."""
        result = classify_product("Chicken Wings")
        assert result.domain == "food"

    def test_apple_juice_is_food(self):
        """Juice should classify as food."""
        result = classify_product("Apple Juice")
        assert result.domain == "food"

    def test_sliced_almonds_has_taxonomy(self):
        """Sliced almonds should get a taxonomy category."""
        result = classify_product("Sliced Almonds 250 g")
        assert result.domain == "food"
        assert result.taxonomy is not None
        assert result.taxonomy_status in ("PASS", "AMBIGUOUS")

    def test_water_has_taxonomy(self):
        """Water should classify as BEVERAGES."""
        result = classify_product("Natural Spring Water 4 L")
        assert result.domain == "food"
        assert result.taxonomy is not None
        if result.taxonomy_status == "PASS":
            assert result.taxonomy == "BEVERAGES"