py47 lines1.8 KB
| 1 | from leads.portfolio import build_portfolios |
| 2 | |
| 3 | |
| 4 | def parcel(city, pid, owner, value, mail="100 Quarry Rd"): |
| 5 | return {"city": city, "parcel_id": pid, "owner_name": owner, "total_value": value, |
| 6 | "mailing_address": mail, "mailing_city": "Ashgrove", "mailing_state": "ZZ", |
| 7 | "mailing_zip": "00000"} |
| 8 | |
| 9 | |
| 10 | PARCELS = [ |
| 11 | parcel("ASH", "A-1", "Halvard Harbor Holdings LLC", "400000"), |
| 12 | parcel("ASH", "A-2", "HALVARD HARBOR HOLDINGS, L.L.C.", "250000"), |
| 13 | parcel("KES", "K-9", "Halvard Harbor Holdings LLC", "1000000"), |
| 14 | parcel("KES", "K-9", "Halvard Harbor Holdings LLC", "1000000"), # repeated parcel id |
| 15 | parcel("ASH", "A-3", "Pellworth Anna M", "180000"), |
| 16 | parcel("KES", "K-4", "Quillon Family Trust", "90000"), |
| 17 | parcel("KES", "K-5", "", "50000"), # blank owner |
| 18 | ] |
| 19 | |
| 20 | |
| 21 | def test_one_portfolio_per_owner_with_totals(): |
| 22 | rows, _ = build_portfolios(PARCELS, city_order=["ASH", "KES"]) |
| 23 | top = rows[0] |
| 24 | assert top["name"] == "HALVARD HARBOR HOLDINGS LLC" |
| 25 | assert top["tier"] == "BUSINESS" |
| 26 | assert top["total_parcels"] == 3 |
| 27 | assert top["n_cities"] == 2 |
| 28 | assert top["cities"] == "ASH:2 KES:1" |
| 29 | assert top["total_assessed_value"] == "1650000" |
| 30 | assert top["name_variants"] == 2 |
| 31 | |
| 32 | |
| 33 | def test_largest_portfolio_sorts_first(): |
| 34 | rows, _ = build_portfolios(PARCELS) |
| 35 | counts = [r["total_parcels"] for r in rows] |
| 36 | assert counts == sorted(counts, reverse=True) |
| 37 | |
| 38 | |
| 39 | def test_trusts_are_quarantined_not_dropped(): |
| 40 | rows, trusts = build_portfolios(PARCELS) |
| 41 | assert [r["name"] for r in trusts] == ["QUILLON FAMILY TRUST"] |
| 42 | assert all("TRUST" not in r["name"] for r in rows) |
| 43 | |
| 44 | |
| 45 | def test_blank_owner_rows_are_skipped(): |
| 46 | rows, trusts = build_portfolios(PARCELS) |
| 47 | assert sum(r["total_parcels"] for r in rows + trusts) == 5 |