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.4 KiB
Python

"""Tests for the employer scope gate (mission-driven employers only)."""
from gimme_job.proactive.employer_scope import (
ACADEMIC,
GOVERNMENT,
MISSION,
NONPROFIT,
PRIVATE,
PUBLIC_HEALTH,
PUBLIC_TYPES,
TRIBAL,
UNKNOWN,
classify_employer,
read_employer_candidates,
record_employer_candidate,
)
from gimme_job.proactive.plan import ProactivePlan
def _plan() -> ProactivePlan:
plan = ProactivePlan()
plan.verification.public_domains = ["myclinic.org"]
plan.verification.employer_terms = {"tribal": ["cherokee nation"]}
return plan
def test_government_host_suffix():
assert classify_employer("https://www.ihs.gov/jobs/1", "Orthodontist")[0] == GOVERNMENT
host_type, reason = classify_employer("https://careers.example.mil/job/1", "")
assert host_type == GOVERNMENT and "host" in reason
def test_academic_and_tribal_host_suffixes():
assert classify_employer("https://dentistry.utah.edu/job/1", "")[0] == ACADEMIC
assert classify_employer("https://jobs.hopi-nsn.us/job/1", "")[0] == TRIBAL
def test_public_domain_allowlist():
etype, reason = classify_employer(
"https://careers.gilariver.org/jobs/123", "Orthodontist"
)
assert etype == MISSION and "public domain" in reason
assert classify_employer("https://www.governmentjobs.com/careers/az", "")[0] == MISSION
def test_configured_public_domain_and_terms():
plan = _plan()
assert classify_employer("https://jobs.myclinic.org/x", "", plan)[0] == MISSION
etype, reason = classify_employer(
"https://careers-cherokee.icims.com/jobs/1", "Orthodontist - Cherokee Nation", plan
)
assert etype == TRIBAL and "cherokee nation" in reason
def test_employer_keyword_types():
assert (
classify_employer("https://jobs.example.com/1", "Orthodontist - Cherokee Nation")[0]
== TRIBAL
)
assert (
classify_employer("https://jobs.example.com/2", "Navajo Area Indian Health Service")[0]
== TRIBAL
)
assert (
classify_employer("https://jobs.example.com/3", "State of Arizona Dentist")[0]
== GOVERNMENT
)
assert (
classify_employer("https://jobs.example.com/4", "University of Utah Health")[0]
== ACADEMIC
)
assert (
classify_employer("https://jobs.example.com/5", "Community Health Center Dentist")[0]
== PUBLIC_HEALTH
)
assert (
classify_employer("https://jobs.example.com/6", "Nonprofit clinic orthodontist")[0]
== NONPROFIT
)
def test_private_terms_win():
etype, reason = classify_employer(
"https://jobs.example.com/1",
"Orthodontist - Smile Doctors, a dental service organization",
)
assert etype == PRIVATE and "dental service organization" in reason
def test_unknown_is_default_deny():
etype, reason = classify_employer(
"https://job-boards.greenhouse.io/specialtydentalbrands/jobs/1",
"Job Application for Orthodontist at Specialty Dental Brands",
)
assert etype == UNKNOWN
assert etype not in PUBLIC_TYPES
assert "no mission-driven" in reason
def test_record_and_read_employer_candidates():
record_employer_candidate(
"https://gh/j/1", PRIVATE, "dental service organization", title="Orthodontist"
)
record_employer_candidate("https://gh/j/2", GOVERNMENT, "host", title="Orthodontist")
entries = read_employer_candidates()
assert len(entries) == 1
assert entries[0]["employer_type"] == PRIVATE