Spaces:
Sleeping
Sleeping
File size: 2,226 Bytes
b2ef214 | 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 | """
Unit tests for pure-logic functions in src/classifier/predict.py.
No model checkpoint required. Tests _keyword_classify() directly.
Run: pytest tests/classifier/test_model.py
"""
from src.classifier.model import DOMAIN_LABELS
from src.classifier.predict import _keyword_classify
# ---------------------------------------------------------------------------
# Domain routing
# ---------------------------------------------------------------------------
def test_keyword_classify_telecom():
result = _keyword_classify("Airtel deducted from my prepaid account without explanation")
assert result.domain == "telecom"
def test_keyword_classify_banking():
result = _keyword_classify("HDFC Bank deducted funds from my savings account without authorization")
assert result.domain == "banking"
def test_keyword_classify_ecommerce():
result = _keyword_classify("Flipkart has not delivered my order and refused to refund")
assert result.domain == "ecommerce"
def test_keyword_classify_insurance():
result = _keyword_classify("LIC rejected my health insurance claim without reason")
assert result.domain == "insurance"
def test_keyword_classify_cibil():
result = _keyword_classify("My CIBIL credit score dropped due to an incorrect entry")
assert result.domain == "cibil"
def test_keyword_classify_no_keyword_falls_back_to_general():
result = _keyword_classify("I have a problem with a service I received")
assert result.domain == "general"
# ---------------------------------------------------------------------------
# Sentinel values — always 0.0 / True regardless of input
# ---------------------------------------------------------------------------
def test_keyword_classify_confidence_is_zero():
result = _keyword_classify("Airtel deducted from my prepaid account")
assert result.confidence == 0.0
def test_keyword_classify_low_confidence_is_true():
result = _keyword_classify("Airtel deducted from my prepaid account")
assert result.low_confidence is True
def test_keyword_classify_all_probs_has_six_keys():
result = _keyword_classify("Flipkart did not deliver my order")
assert set(result.all_probs.keys()) == set(DOMAIN_LABELS)
|