Initial build out
This commit is contained in:
parent
f037c50736
commit
29215e2bd2
40 changed files with 2622 additions and 0 deletions
46
tests/test_irs990_loader.py
Normal file
46
tests/test_irs990_loader.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
from admin_analytics.irs990.loader import load_filing, load_part_vii, load_schedule_j
|
||||
|
||||
|
||||
def test_load_filing(db_conn, fixtures_dir):
|
||||
xml_path = fixtures_dir / "990_sample.xml"
|
||||
assert load_filing(db_conn, xml_path, "TEST001")
|
||||
|
||||
row = db_conn.execute(
|
||||
"SELECT ein, tax_year, organization_name, total_expenses FROM raw_990_filing WHERE object_id = 'TEST001'"
|
||||
).fetchone()
|
||||
assert row[0] == "516000297"
|
||||
assert row[1] == 2022
|
||||
assert row[2] == "UNIVERSITY OF DELAWARE"
|
||||
assert row[3] == 1700000000
|
||||
|
||||
|
||||
def test_load_filing_idempotent(db_conn, fixtures_dir):
|
||||
xml_path = fixtures_dir / "990_sample.xml"
|
||||
load_filing(db_conn, xml_path, "TEST001")
|
||||
load_filing(db_conn, xml_path, "TEST001") # second load should overwrite
|
||||
count = db_conn.execute(
|
||||
"SELECT COUNT(*) FROM raw_990_filing WHERE object_id = 'TEST001'"
|
||||
).fetchone()[0]
|
||||
assert count == 1
|
||||
|
||||
|
||||
def test_load_part_vii(db_conn, fixtures_dir):
|
||||
xml_path = fixtures_dir / "990_sample.xml"
|
||||
count = load_part_vii(db_conn, xml_path, "TEST001")
|
||||
assert count == 3
|
||||
|
||||
rows = db_conn.execute(
|
||||
"SELECT person_name, reportable_comp_from_org FROM raw_990_part_vii WHERE object_id = 'TEST001' ORDER BY reportable_comp_from_org DESC"
|
||||
).fetchall()
|
||||
assert rows[0] == ("JOHN DOE", 850000)
|
||||
|
||||
|
||||
def test_load_schedule_j(db_conn, fixtures_dir):
|
||||
xml_path = fixtures_dir / "990_sample.xml"
|
||||
count = load_schedule_j(db_conn, xml_path, "TEST001")
|
||||
assert count == 2
|
||||
|
||||
row = db_conn.execute(
|
||||
"SELECT person_name, base_compensation, total_compensation FROM raw_990_schedule_j WHERE object_id = 'TEST001' AND person_name = 'JOHN DOE'"
|
||||
).fetchone()
|
||||
assert row == ("JOHN DOE", 700000, 950000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue