File size: 815 Bytes
d4f8959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from backend.sector import detect_sector


def test_bank_text_detected():
    text = (
        "The bank reported total deposits and advances. NIM improved. "
        "Gross NPA declined. CASA ratio stood at 45%. RBI guidelines followed."
    )
    assert detect_sector(text) == "BANK"


def test_it_text_detected():
    text = (
        "TCS reported strong growth across IT services. "
        "Attrition was 12%. Offshore delivery and software exports grew."
    )
    assert detect_sector(text) == "IT"


def test_generic_text_falls_back_to_general():
    assert detect_sector("The company reported strong results this year.") == "GENERAL"


def test_fewer_than_three_keyword_hits_is_general():
    # one keyword alone shouldn't flip the sector
    assert detect_sector("Some deposits were made.") == "GENERAL"