Read Greenhouse, Lever, Ashby, Workable, SmartRecruiters, Recruitee and
Personio boards The `ats` plugin: one Source per host's public JSON (Personio: XML), each parsed to a common row and yielded as a `role` item. The field map, the redirect allow-list, the 8 MB cap and the 10 s timeout are ported from jobhunt-hq's openings.go (MIT); the nine-function classifier is ported from its seedgen. Workable, SmartRecruiters, Recruitee and Personio are new, written from one real board of each fetched while this was built. Fixtures under tests/fixtures/ats/ keep every test off the network. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac5eca874a
commit
21ed472a87
10 files changed
+909
No files matched your search
@@ -0,0 +1,134 @@
|
||||
"""The `ats` plugin: each host's parser against a saved feed, the function
|
||||
classifier, and the fetch allow-list. No network — every fixture is a file
|
||||
under `tests/fixtures/ats/`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from plugins import ats # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
|
||||
def _rows(host: str, slug: str = "acme") -> list[ats.Row]:
|
||||
path = FIXTURES / f"{host}.{'xml' if host == 'personio' else 'json'}"
|
||||
body = path.read_bytes()
|
||||
return ats._PARSERS[host](body, slug)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ hosts
|
||||
|
||||
def test_greenhouse_parses_titles_locations_and_html_description() -> None:
|
||||
rows = _rows("greenhouse")
|
||||
# The javascript: and data: rows are refused, same as the two real ones
|
||||
# are kept: a feed is external content, never trusted as a URL.
|
||||
assert [r["source_id"] for r in rows] == ["1001", "1002"]
|
||||
first = rows[0]
|
||||
assert first["title"] == "Senior Backend Engineer" # trimmed
|
||||
assert first["location"] == "Berlin, Germany"
|
||||
assert first["department"] == "Engineering"
|
||||
assert first["description"] == "Build our core platform."
|
||||
assert first["posted"] is not None and first["posted"].year == 2026
|
||||
assert first["remote"] is None
|
||||
|
||||
|
||||
def test_lever_parses_categories_and_workplace_type() -> None:
|
||||
rows = _rows("lever")
|
||||
assert [r["source_id"] for r in rows] == ["2001", "2002"]
|
||||
first = rows[0]
|
||||
assert first["department"] == "Engineering"
|
||||
assert first["remote"] == "remote"
|
||||
assert first["description"] == "Own our platform reliability."
|
||||
# createdAt=0 means "no date", not epoch zero.
|
||||
assert rows[1]["posted"] is None
|
||||
|
||||
|
||||
def test_ashby_parses_is_remote_and_compensation() -> None:
|
||||
rows = _rows("ashby")
|
||||
assert [r["source_id"] for r in rows] == ["3001", "3002"]
|
||||
assert rows[0]["remote"] is False
|
||||
assert rows[0]["salary"] == "70,000-90,000 EUR"
|
||||
assert rows[1]["remote"] is True
|
||||
|
||||
|
||||
def test_workable_parses_location_parts_and_telecommute() -> None:
|
||||
rows = _rows("workable")
|
||||
assert [r["source_id"] for r in rows] == ["4001", "4002"]
|
||||
assert rows[0]["location"] == "Berlin, Germany"
|
||||
assert rows[0]["remote"] is True
|
||||
assert "Ship our API." in rows[0]["description"]
|
||||
|
||||
|
||||
def test_smartrecruiters_builds_the_job_url_from_id_and_slug() -> None:
|
||||
rows = _rows("smartrecruiters", slug="Acme")
|
||||
assert [r["source_id"] for r in rows] == ["744000151326819", "744000147485112"]
|
||||
assert rows[0]["url"] == "https://jobs.smartrecruiters.com/Acme/744000151326819"
|
||||
assert rows[0]["location"] == "Berlin, Germany"
|
||||
assert rows[1]["remote"] is True
|
||||
|
||||
|
||||
def test_recruitee_parses_salary_bounds_and_careers_url() -> None:
|
||||
rows = _rows("recruitee")
|
||||
assert [r["source_id"] for r in rows] == ["5001", "5002"]
|
||||
assert rows[0]["url"] == "https://acme.example/o/player-support-agent-german-1"
|
||||
assert rows[0]["salary"] == "35000-45000 EUR"
|
||||
assert rows[1]["salary"] == ""
|
||||
|
||||
|
||||
def test_personio_builds_the_job_url_and_reads_cdata_description() -> None:
|
||||
rows = _rows("personio", slug="acme")
|
||||
assert [r["source_id"] for r in rows] == ["6001", "6002"]
|
||||
assert rows[0]["url"] == "https://acme.jobs.personio.de/job/6001"
|
||||
assert rows[0]["description"] == "Grow our pipeline."
|
||||
assert rows[0]["remote"] is True # "Remote - Germany"
|
||||
assert rows[1]["remote"] is None # "Munich"
|
||||
|
||||
|
||||
# --------------------------------------------------------------- classify
|
||||
|
||||
def test_classify_matches_department_before_title() -> None:
|
||||
assert ats.classify("Engineering", "Marketing Lead") == "engineering"
|
||||
assert ats.classify("", "Senior Backend Engineer") == "engineering"
|
||||
assert ats.classify("", "Product Manager, Payments") == "product"
|
||||
assert ats.classify("", "Data Product Manager") == "product"
|
||||
assert ats.classify("", "Machine Learning Engineer") == "data"
|
||||
assert ats.classify("", "Executive Assistant to the CEO") == "finance/legal/ops"
|
||||
assert ats.classify("", "") == "other"
|
||||
|
||||
|
||||
# ------------------------------------------------------------- allow-list
|
||||
|
||||
def test_is_known_target_accepts_the_seven_hosts_and_refuses_others() -> None:
|
||||
for host in ("greenhouse", "lever", "ashby", "workable", "smartrecruiters",
|
||||
"recruitee", "personio"):
|
||||
assert ats.is_known_target(f"{host}:acme")
|
||||
assert not ats.is_known_target("linkedin:acme")
|
||||
assert not ats.is_known_target("workday:acme")
|
||||
assert not ats.is_known_target("greenhouse:")
|
||||
assert not ats.is_known_target("nohostnoseparator")
|
||||
|
||||
|
||||
def test_allowed_host_refuses_a_foreign_host_per_board() -> None:
|
||||
allow = ats._allowed_host("greenhouse", "acme")
|
||||
assert allow("boards-api.greenhouse.io")
|
||||
assert not allow("boards-api.greenhouse.io.evil.example")
|
||||
assert not allow("api.lever.co")
|
||||
|
||||
# recruitee and personio key off the company's own subdomain, so one
|
||||
# company's slug must not pass for another's.
|
||||
allow_recruitee = ats._allowed_host("recruitee", "acme")
|
||||
assert allow_recruitee("acme.recruitee.com")
|
||||
assert not allow_recruitee("other.recruitee.com")
|
||||
|
||||
|
||||
def test_careers_url_is_filled_per_host_and_empty_for_unknown() -> None:
|
||||
assert ats.careers_url("greenhouse:acme") == "https://job-boards.greenhouse.io/acme"
|
||||
assert ats.careers_url("ashby:acme") == "https://jobs.ashbyhq.com/acme"
|
||||
assert ats.careers_url("recruitee:acme") == "https://acme.recruitee.com"
|
||||
assert ats.careers_url("workday:acme") == ""
|
||||
Reference in new issue
Block a user