| from backend.entity_resolver import resolve_entity, normalize_org_name, format_money |
|
|
|
|
| EXISTING = ["Apple", "HDFC Bank", "3M"] |
|
|
|
|
| def test_alias_table_resolves_ticker(): |
| assert resolve_entity("AAPL", "ORG", EXISTING) == "ORG_Apple" |
|
|
|
|
| def test_legal_suffix_stripped(): |
| assert resolve_entity("Apple Inc.", "ORG", EXISTING) == "ORG_Apple" |
| assert resolve_entity("HDFC Bank Limited", "ORG", EXISTING) == "ORG_HDFC Bank" |
|
|
|
|
| def test_short_name_not_mangled(): |
| assert resolve_entity("3M Company", "ORG", EXISTING) == "ORG_3M" |
|
|
|
|
| def test_non_org_labels_pass_through(): |
| assert resolve_entity("$394.3 billion", "MONEY", EXISTING).startswith("MONEY_") |
|
|
|
|
| def test_normalize_strips_trailing_suffixes_only(): |
| assert normalize_org_name("Reliance Industries Limited") == "reliance" |
| |
| assert normalize_org_name("Industries First Corp") == "industries first" |
|
|
|
|
| def test_format_money_inr_crore(): |
| |
| assert format_money(60_812 * 10_000_000, "INR") == "₹60,812.0 Cr" |
|
|
|
|
| def test_format_money_inr_lakh_crore(): |
| assert "Lakh Cr" in format_money(2.7e13, "INR") |
|
|
|
|
| def test_format_money_usd(): |
| assert format_money(394_300_000_000, "USD") == "$394.3B" |
| assert format_money(45_000_000, "USD") == "$45.0M" |
|
|
|
|
| def test_format_money_none(): |
| assert format_money(None) == "N/A" |
|
|