osint-lead-identificationPortfolio

py54 lines1.9 KB
Raw
1import pytest
2
3from leads.classify import TIER_ORDER, classify, group_key, norm_display
4
5
6def tier(name):
7 return classify(group_key(norm_display(name).upper()))
8
9
10@pytest.mark.parametrize("name, expected", [
11 ("Kestrel Bay Holdings LLC", "BUSINESS"),
12 ("Halvard Harbor Holdings, L.L.C.", "BUSINESS"),
13 ("Home Goods USA Inc", "BUSINESS"),
14 ("Bramble Roofing LLC", "TRADE"),
15 ("Meriden Electric Co", "TRADE"),
16 ("Halvard Electric and Power Company", "UTILITY"),
17 ("Northgate Railway", "UTILITY"),
18 ("City of Port Halvard", "GOVERNMENT"),
19 ("Marrowfield Housing Authority", "GOVERNMENT"),
20 ("Ashgrove Industrial Development Authority", "GOVERNMENT"),
21 ("USA", "GOVERNMENT"),
22 ("First Church of Ashgrove", "RELIGIOUS"),
23 ("Linden Ridge Homeowners Association", "HOA"),
24 ("Quillon Family Trust", "TRUST"),
25 ("Selby Truste", "TRUST"),
26 ("Ostrander & Sons", "AMBIGUOUS"),
27 ("J & J Auto Services", "AMBIGUOUS"),
28 ("412 Wren Street", "AMBIGUOUS"),
29 ("Ostrander David G & Ostrander Karla", "INDIVIDUAL"),
30 ("Pellworth Anna M", "INDIVIDUAL"),
31])
32def test_tiers(name, expected):
33 assert tier(name) == expected
34
35
36@pytest.mark.parametrize("name", ["Trusty Owen P", "Upchurch Ellis R", "Corporan Dale"])
37def test_surnames_are_not_caught_by_substring(name):
38 assert tier(name) == "INDIVIDUAL"
39
40
41def test_trust_word_inside_a_company_name_stays_business():
42 assert tier("Quillon Trustmark Properties LLC") == "BUSINESS"
43
44
45def test_first_match_wins_in_tier_order():
46 # a church-owned holding company is RELIGIOUS, because RELIGIOUS is checked first
47 assert tier("Grace Church Holdings LLC") == "RELIGIOUS"
48 assert TIER_ORDER.index("RELIGIOUS") < TIER_ORDER.index("BUSINESS")
49
50
51def test_spelling_variants_share_one_group_key():
52 a = group_key(norm_display("Halvard Harbor Holdings, L.L.C.").upper())
53 b = group_key(norm_display("HALVARD HARBOR HOLDINGS LLC.").upper())
54 assert a == b == "HALVARD HARBOR HOLDINGS LLC"