Initial build out
This commit is contained in:
parent
f037c50736
commit
29215e2bd2
40 changed files with 2622 additions and 0 deletions
41
tests/test_ipeds_institution.py
Normal file
41
tests/test_ipeds_institution.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import shutil
|
||||
|
||||
import admin_analytics.config as config
|
||||
from admin_analytics.config import UD_UNITID
|
||||
from admin_analytics.ipeds.institution import load_institutions
|
||||
|
||||
|
||||
def test_load_institutions_filters_to_ud(db_conn, fixtures_dir, tmp_path):
|
||||
"""HD loader should only load UD's row when unitid_filter is set."""
|
||||
ipeds_dir = tmp_path / "ipeds" / "hd" / "2023"
|
||||
ipeds_dir.mkdir(parents=True)
|
||||
shutil.copy(fixtures_dir / "hd2023.csv", ipeds_dir / "hd2023.csv")
|
||||
|
||||
original = config.IPEDS_DATA_DIR
|
||||
config.IPEDS_DATA_DIR = tmp_path / "ipeds"
|
||||
try:
|
||||
count = load_institutions(db_conn, range(2023, 2024), unitid_filter=UD_UNITID)
|
||||
finally:
|
||||
config.IPEDS_DATA_DIR = original
|
||||
|
||||
assert count == 1
|
||||
rows = db_conn.execute("SELECT * FROM raw_institution").fetchall()
|
||||
assert len(rows) == 1
|
||||
assert rows[0][0] == UD_UNITID
|
||||
assert rows[0][3] == "University of Delaware"
|
||||
|
||||
|
||||
def test_load_institutions_no_filter(db_conn, fixtures_dir, tmp_path):
|
||||
"""Without filter, all institutions should load."""
|
||||
ipeds_dir = tmp_path / "ipeds" / "hd" / "2023"
|
||||
ipeds_dir.mkdir(parents=True)
|
||||
shutil.copy(fixtures_dir / "hd2023.csv", ipeds_dir / "hd2023.csv")
|
||||
|
||||
original = config.IPEDS_DATA_DIR
|
||||
config.IPEDS_DATA_DIR = tmp_path / "ipeds"
|
||||
try:
|
||||
count = load_institutions(db_conn, range(2023, 2024), unitid_filter=None)
|
||||
finally:
|
||||
config.IPEDS_DATA_DIR = original
|
||||
|
||||
assert count == 2
|
||||
Loading…
Add table
Add a link
Reference in a new issue