Order the hosts by a RANK per module, which restores the select's and the probes' order from before the modules
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
75a389d725
commit
a9fb4397ac
11 files changed
+71
-8
No files matched your search
+26
-2
@@ -28,10 +28,10 @@ FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
# --------------------------------------------------------------- registry
|
||||
|
||||
def test_the_registry_finds_every_module_in_order_of_name() -> None:
|
||||
def test_the_registry_finds_every_module() -> None:
|
||||
names = sorted(p.stem for p in (ROOT / "plugins" / "atshosts").glob("*.py")
|
||||
if not p.stem.startswith("_"))
|
||||
assert list(atshosts.HOSTS) == names
|
||||
assert sorted(atshosts.HOSTS) == names
|
||||
assert set(names) >= {"greenhouse", "lever", "ashby", "workable", "smartrecruiters",
|
||||
"recruitee", "personio", "teamtailor"}
|
||||
assert all(not atshosts.problems(module, name) for name, module in atshosts.HOSTS.items())
|
||||
@@ -71,6 +71,28 @@ def test_the_registry_loads_a_package_by_name_and_skips_private_modules(
|
||||
assert list(atshosts.load(path, "hostsok")) == ["alpha", "zeta"]
|
||||
|
||||
|
||||
def test_the_registry_orders_by_rank_then_name(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
path = _package(tmp_path, monkeypatch, "hostsranked", {
|
||||
"alpha": _GOOD.format(name="alpha"), # the default, 100
|
||||
"beta": _GOOD.format(name="beta") + "RANK = 5\n",
|
||||
"gamma": _GOOD.format(name="gamma") + "RANK = 100\n"})
|
||||
assert list(atshosts.load(path, "hostsranked")) == ["beta", "alpha", "gamma"]
|
||||
|
||||
|
||||
def test_the_eight_first_hosts_keep_the_order_they_had_before_modules() -> None:
|
||||
"""The Sources page's select opens on Greenhouse, which its hint names,
|
||||
and a guessed slug on two hosts goes to the one probed first, as before."""
|
||||
first = ["greenhouse", "lever", "ashby", "workable", "smartrecruiters", "recruitee",
|
||||
"personio", "teamtailor"]
|
||||
assert list(ats.HOSTS)[:8] == first
|
||||
assert ats.ATSSource.description.startswith(
|
||||
"Company job boards: Greenhouse, Lever, Ashby, Workable, SmartRecruiters, "
|
||||
"Recruitee, Personio, Teamtailor")
|
||||
assert all(module.RANK < atshosts.DEFAULT_RANK
|
||||
for name, module in atshosts.HOSTS.items() if name in first)
|
||||
|
||||
|
||||
def test_the_registry_refuses_a_module_missing_a_required_name(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
broken = _GOOD.format(name="broken").replace("def careers_url", "def not_careers_url")
|
||||
@@ -85,12 +107,14 @@ def test_the_contract_check_names_each_problem() -> None:
|
||||
module.slug_ok = module.allowed = module.careers_url = lambda slug: ""
|
||||
module.page = lambda get, slug, cursor: None
|
||||
module.probe_ok = lambda body: True
|
||||
module.RANK, module.KEEP_CASE = "1", "yes"
|
||||
found = atshosts.problems(module, "odd")
|
||||
assert "NAME is 'other', not the module's name 'odd'" in found
|
||||
assert "LABEL is not a non-empty string" in found
|
||||
assert any(p.startswith("PATTERNS has '('") for p in found)
|
||||
assert "page without rows" in found
|
||||
assert "probe_ok without probe_url" in found
|
||||
assert "RANK is not an int" in found and "KEEP_CASE is not a bool" in found
|
||||
|
||||
|
||||
# ------------------------------------------------------------ the fetch
|
||||
|
||||
@@ -268,6 +268,29 @@ def test_slug_probes_find_a_board_the_pages_never_link() -> None:
|
||||
assert found.evidence == "https://api.ashbyhq.com/posting-api/job-board/acme"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("boards", "found"), [
|
||||
({("greenhouse", "acme"), ("ashby", "acme")}, "greenhouse:acme"),
|
||||
({("lever", "acme"), ("ashby", "acme")}, "lever:acme"),
|
||||
({("smartrecruiters", "acme"), ("personio", "acme")}, "smartrecruiters:acme"),
|
||||
({("lever", "eu/acme"), ("personio", "acme")}, "lever:eu/acme"),
|
||||
])
|
||||
def test_a_slug_on_two_hosts_goes_to_the_one_probed_first(
|
||||
boards: set[tuple[str, str]], found: str) -> None:
|
||||
site = Site({}, boards=boards)
|
||||
assert run(site).board == found
|
||||
|
||||
|
||||
def test_the_probe_order_is_the_one_before_modules() -> None:
|
||||
assert list(mod._PROBES)[:7] == ["greenhouse", "lever", "ashby", "smartrecruiters",
|
||||
"recruitee", "personio", "teamtailor"]
|
||||
site = Site({})
|
||||
run(site)
|
||||
assert site.probed[:8] == [("greenhouse", "acme"), ("lever", "acme"), ("lever", "eu/acme"),
|
||||
("ashby", "acme"), ("smartrecruiters", "acme"),
|
||||
("recruitee", "acme"), ("personio", "acme"),
|
||||
("teamtailor", "acme")]
|
||||
|
||||
|
||||
def test_a_lever_eu_board_is_found_by_its_probe() -> None:
|
||||
site = Site({"https://acme.com/": "<p>a script draws the jobs</p>"},
|
||||
boards={("lever", "eu/acme")})
|
||||
|
||||
Reference in new issue
Block a user