AdminAnalytics/tests/test_irs990_download.py
2026-03-30 07:15:14 -04:00

25 lines
1.1 KiB
Python

import admin_analytics.config as config
from admin_analytics.irs990.download import filter_index
def test_filter_index(fixtures_dir, tmp_path):
"""Test that index filtering finds UD filings and skips 990T."""
# Create a mock index CSV
index = tmp_path / "index_2023.csv"
index.write_text(
"RETURN_ID,FILING_TYPE,EIN,TAX_PERIOD,SUB_DATE,TAXPAYER_NAME,RETURN_TYPE,DLN,OBJECT_ID\n"
"1,EFILE,516000297,202206,2023,UNIVERSITY OF DELAWARE,990,123,OBJ001\n"
"2,EFILE,516000297,202206,2023,UNIVERSITY OF DELAWARE,990T,456,OBJ002\n"
"3,EFILE,516017306,202212,2023,UNIVERSITY OF DELAWARE RESEARCH FOUNDATION,990,789,OBJ003\n"
"4,EFILE,999999999,202212,2023,SOME OTHER ORG,990,000,OBJ004\n"
)
result = filter_index(index, config.UD_EINS)
assert result.height == 2 # UD 990 + Research Foundation 990, not 990T
eins = result["EIN"].to_list()
assert "516000297" in eins
assert "516017306" in eins
# All should be type 990 (not 990T)
assert all(rt == "990" for rt in result["RETURN_TYPE"].to_list())