You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.6 KiB
Python
107 lines
3.6 KiB
Python
"""Tests for proactive query matrix generation."""
|
|
from datetime import date
|
|
|
|
from gimme_job.proactive.plan import ProactivePlan
|
|
|
|
|
|
def test_plan_loads():
|
|
plan = ProactivePlan.load()
|
|
assert len(plan.states) >= 51 # 50 states + DC minimum
|
|
assert "orthodontist" in plan.terms.title
|
|
assert plan.engines.order[0] == "duckduckgo"
|
|
|
|
|
|
def test_all_states_covered_every_day():
|
|
plan = ProactivePlan.load()
|
|
queries = plan.generate_queries(date(2026, 9, 8))
|
|
for state in plan.states:
|
|
assert any(f" {state}" in q or q.endswith(f" {state}") for q in queries), (
|
|
f"state not covered: {state}"
|
|
)
|
|
|
|
|
|
def test_budget_cap_respected():
|
|
plan = ProactivePlan.load()
|
|
queries = plan.generate_queries(date(2026, 9, 8))
|
|
assert len(queries) <= plan.budget.max_queries_per_day
|
|
assert len(queries) >= len(plan.states) # at least one query per state
|
|
|
|
|
|
def test_deterministic_same_date():
|
|
plan = ProactivePlan.load()
|
|
q1 = plan.generate_queries(date(2026, 9, 8))
|
|
q2 = plan.generate_queries(date(2026, 9, 8))
|
|
assert q1 == q2
|
|
|
|
|
|
def test_rotation_changes_over_days():
|
|
plan = ProactivePlan.load()
|
|
q1 = plan.generate_queries(date(2026, 9, 8))
|
|
q2 = plan.generate_queries(date(2026, 9, 9))
|
|
assert q1 != q2
|
|
# First state's setting term should rotate to the next setting
|
|
s1 = next(q for q in q1 if q.endswith(f" {plan.states[0]}"))
|
|
s2 = next(q for q in q2 if q.endswith(f" {plan.states[0]}"))
|
|
assert s1 != s2
|
|
|
|
|
|
def test_oconus_queries_present():
|
|
plan = ProactivePlan.load()
|
|
queries = plan.generate_queries(date(2026, 9, 8))
|
|
oconus = plan.oconus.all_queries()
|
|
assert any(q in oconus for q in queries)
|
|
|
|
|
|
def test_state_for_query():
|
|
plan = ProactivePlan.load()
|
|
assert plan.state_for_query("FQHC orthodontist Alabama") == "Alabama"
|
|
assert plan.state_for_query("orthodontist FQHC job") is None
|
|
|
|
|
|
def test_hidden_title_state_rotation():
|
|
"""Every state gets a hidden-title query within the rotation window (doc §4)."""
|
|
plan = ProactivePlan.load()
|
|
rot = plan.budget.hidden_title_rotation_days
|
|
seen: dict[str, int] = {}
|
|
for day_offset in range(rot):
|
|
queries = plan.generate_queries(date(2026, 9, 8 + day_offset))
|
|
for q in queries:
|
|
st = plan.state_for_query(q)
|
|
if st:
|
|
seen[st] = seen.get(st, 0) + 1
|
|
for state in plan.states:
|
|
assert seen.get(state, 0) >= 1, f"hidden-title never covers {state}"
|
|
|
|
|
|
def test_national_pool_has_recruitment_phrases():
|
|
plan = ProactivePlan.load()
|
|
pool = plan._national_pool()
|
|
assert any("hiring orthodontist" in p for p in pool)
|
|
assert any("orthodontist openings" in p for p in pool)
|
|
|
|
|
|
def test_employers_catalog_loaded():
|
|
plan = ProactivePlan.load()
|
|
boards = plan.employers.all_boards()
|
|
assert any(b.source == "smartrecruiters" for b in boards)
|
|
assert any(b.source == "usajobs" for b in boards)
|
|
# each board carries its source and a name
|
|
for b in boards:
|
|
assert b.source and b.name
|
|
|
|
|
|
def test_denylist():
|
|
plan = ProactivePlan.load()
|
|
# job_id-specific entry: only denylisted when the exact requisition matches
|
|
assert plan.is_denylisted("OHSU Oregon Health", "2025-35294")
|
|
assert not plan.is_denylisted("OHSU Oregon Health")
|
|
# employer-only entry matches any employer string
|
|
assert plan.is_denylisted("PCHC Bangor")
|
|
assert plan.is_denylisted("Some Other Employer") is False
|
|
|
|
|
|
def test_enabled_engines():
|
|
plan = ProactivePlan.load()
|
|
engines = plan.enabled_engines()
|
|
assert "duckduckgo" in engines
|
|
assert all(name in plan.engines.order for name in engines) |