my-homelab-configs/tests/jeannie/test_nextpath_opportunity_r...

35 lines
1.3 KiB
Python

import importlib.util
import pathlib
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[2]
SPEC = importlib.util.spec_from_file_location(
"nextpath_refresh", ROOT / "scripts" / "nextpath-opportunity-refresh.py"
)
MODULE = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(MODULE)
class NextPathOpportunityRefreshTests(unittest.TestCase):
def test_completions_deduplicate_branches(self):
programs = [
{"code": "11.07", "ope6_id": "one", "counts": {"ipeds_awards1": 10}},
{"code": "1107", "ope6_id": "one", "counts": {"ipeds_awards1": 8}},
{"code": "1107", "ope6_id": "two", "counts": {"ipeds_awards1": 5}},
{"code": "5138", "ope6_id": "three", "counts": {"ipeds_awards1": 99}},
]
self.assertEqual(MODULE.annual_completions(programs, {"1107"}), 15)
def test_extracts_arizona_projection(self):
body = {"OccupationDetail": [{"Projections": {
"EstimatedYear": "2022", "ProjectedYear": "2032", "Projections": [
{"StateName": "Arizona", "ProjectedAnnualJobOpening": "1,234", "EstimatedYear": "2022", "ProjectedYear": "2032"}
]
}}]}
self.assertEqual(MODULE.projected_openings(body), (1234, "2022-2032"))
if __name__ == "__main__":
unittest.main()