Hosts a to l declare READS: places, teaser, stated seniority and employment
Ashby, BambooHR, Deel, Eightfold, Gem, Greenhouse, HiBob, HR Manager, Jibe, Jobylon and Lever move to feed_url(slug, ask) and page(get, slug, cursor, ask), declare READS with the robots decision, and drop robots_page. Rows carry places (Ashby secondaryLocations, Lever allLocations, Greenhouse offices in place of a Hybrid placeholder), Jobylon keeps its summary as teaser and maps experience and employment, Eightfold reads creationTs as the posting date and Ashby reads workplaceType. Fixtures <name>-places.* and jobylon-teaser.html drive the conformance checks; the eleven names leave UNDECLARED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c0da58da7
commit
f2e652a8da
35 files changed
+1290
-391
No files matched your search
+43
-45
@@ -17,7 +17,7 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import hibob # noqa: E402
|
||||
from plugins.readers import Ask, hibob # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
BOARD = (FIXTURES / "hibob.json").read_bytes()
|
||||
@@ -104,7 +104,7 @@ def test_the_page_sends_the_company_header_and_states_no_total() -> None:
|
||||
seen.append((url, headers))
|
||||
return BOARD
|
||||
|
||||
data, results, total, cursor = hibob.page(get, "Liquidia", None)
|
||||
data, results, total, cursor = hibob.page(get, "Liquidia", None, Ask())
|
||||
assert seen == [(API, {"companyIdentifier": "liquidia", "Accept": "application/json"})]
|
||||
assert len(results) == 5 and all(r["id"] for r in results)
|
||||
assert total is None and cursor is None
|
||||
@@ -113,59 +113,58 @@ def test_the_page_sends_the_company_header_and_states_no_total() -> None:
|
||||
|
||||
def test_a_body_without_the_ads_is_not_a_board() -> None:
|
||||
with pytest.raises(ValueError, match="not a HiBob board"):
|
||||
hibob.page(lambda url, **kw: b'{"error": "unauthorized"}', "acme", None)
|
||||
hibob.page(lambda url, **kw: b'{"error": "unauthorized"}', "acme", None, Ask())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def web(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]:
|
||||
answers: dict[str, Any] = {}
|
||||
def test_the_board_is_one_request_with_the_company_header() -> None:
|
||||
seen: list[tuple[str, dict[str, str] | None]] = []
|
||||
|
||||
def fake_get(client, url, host, slug, *, method="GET", payload=None, headers=None,
|
||||
www_twin=False):
|
||||
def get(url: str, *, method: str = "GET", payload: Any = None,
|
||||
headers: dict[str, str] | None = None) -> bytes:
|
||||
seen.append((url, headers))
|
||||
if not ats._allowed_host(host, slug)(httpx.URL(url).host):
|
||||
raise ats._Refused(url)
|
||||
answer = answers[url]
|
||||
if isinstance(answer, BaseException):
|
||||
raise answer
|
||||
return answer
|
||||
return BOARD
|
||||
|
||||
monkeypatch.setattr(ats, "_get", fake_get)
|
||||
return {"answers": answers, "seen": seen}
|
||||
data, _results, _total, cursor = hibob.page(get, "liquidia", None, Ask())
|
||||
assert len(hibob.rows(data, "liquidia")) == 5 and cursor is None
|
||||
assert [url for url, _ in seen] == [API]
|
||||
assert seen[0][1] is not None and seen[0][1]["companyIdentifier"] == "liquidia"
|
||||
|
||||
|
||||
def test_the_board_is_one_request_and_complete(web: dict[str, Any]) -> None:
|
||||
web["answers"][API] = BOARD
|
||||
with httpx.Client() as client:
|
||||
rows, complete = ats._fetch_rows(client, "hibob:liquidia")
|
||||
assert len(rows) == 5 and complete
|
||||
assert [url for url, _ in web["seen"]] == [API]
|
||||
assert web["seen"][0][1]["companyIdentifier"] == "liquidia"
|
||||
|
||||
|
||||
def test_an_empty_board_is_complete_and_a_401_is_a_failure(web: dict[str, Any]) -> None:
|
||||
web["answers"]["https://acme.careers.hibob.com/api/job-ad"] = b'{"jobAdDetails": []}'
|
||||
def test_an_empty_board_is_no_rows_and_a_401_reaches_the_caller() -> None:
|
||||
data, results, _total, _cursor = hibob.page(
|
||||
lambda url, **kw: b'{"jobAdDetails": []}', "acme", None, Ask())
|
||||
assert hibob.rows(data, "acme") == [] and results == []
|
||||
request = httpx.Request("GET", API)
|
||||
web["answers"][API] = httpx.HTTPStatusError(
|
||||
"401", request=request, response=httpx.Response(401, request=request))
|
||||
with httpx.Client() as client:
|
||||
assert ats._fetch_rows(client, "hibob:acme") == ([], True)
|
||||
with pytest.raises(httpx.HTTPStatusError):
|
||||
ats._fetch_rows(client, "hibob:liquidia")
|
||||
|
||||
def refused(url: str, **kw: Any) -> bytes:
|
||||
raise httpx.HTTPStatusError("401", request=request,
|
||||
response=httpx.Response(401, request=request))
|
||||
|
||||
with pytest.raises(httpx.HTTPStatusError):
|
||||
hibob.page(refused, "liquidia", None, Ask())
|
||||
|
||||
|
||||
def test_the_robots_txt_that_is_the_apps_own_page_allows(web: dict[str, Any]) -> None:
|
||||
"""The host answers /robots.txt with its single-page app's HTML, a 200
|
||||
with no rules."""
|
||||
web["answers"]["https://dixa.careers.hibob.com/robots.txt"] = \
|
||||
b'<!DOCTYPE html><html><head><title>Careers</title></head><body></body></html>'
|
||||
with httpx.Client() as client:
|
||||
ats._check_robots(client, "hibob:dixa")
|
||||
web["answers"]["https://dixa.careers.hibob.com/robots.txt"] = \
|
||||
b"User-agent: *\nDisallow: /\n"
|
||||
with pytest.raises(ats._Disallowed):
|
||||
ats._check_robots(client, "hibob:dixa")
|
||||
def test_each_ad_names_one_site_and_the_host_lists_a_copy_per_site() -> None:
|
||||
dixa = hibob.parse(DIXA, "dixa")
|
||||
assert [r["places"] for r in dixa] == [
|
||||
[{"text": "Copenhagen, Denmark", "remote": False}],
|
||||
[{"text": "London, United Kingdom", "remote": False}]]
|
||||
assert {r["title"] for r in dixa} == {"Expression of interest"}
|
||||
assert len({r["source_id"] for r in dixa}) == 2
|
||||
|
||||
|
||||
def test_the_employment_type_is_mapped_and_a_permanent_one_is_left_unmapped() -> None:
|
||||
rows = hibob.parse(BOARD, "liquidia")
|
||||
assert rows[0]["employment"] == "full_time" # "Regular Full Time"
|
||||
assert "employment" not in hibob.parse(DIXA, "dixa")[0] # "Permanent"
|
||||
|
||||
|
||||
def test_it_declares_copies_with_a_page_and_a_robots_decision() -> None:
|
||||
reads = hibob.READS
|
||||
assert (reads.listing, reads.text, reads.places, reads.complete) == (
|
||||
"paged", "listing", "copies", "end")
|
||||
assert reads.robots.startswith("read: robots.txt allows")
|
||||
assert not hasattr(hibob, "robots_page")
|
||||
|
||||
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
@@ -178,7 +177,6 @@ def test_the_module_is_registered_as_a_paged_host() -> None:
|
||||
|
||||
def test_the_urls_and_the_allowed_host_follow_the_slug() -> None:
|
||||
assert hibob.careers_url("dixa") == "https://dixa.careers.hibob.com/"
|
||||
assert hibob.robots_page("dixa") == "https://dixa.careers.hibob.com/"
|
||||
allow = hibob.allowed("Dixa")
|
||||
assert allow("dixa.careers.hibob.com") and allow("DIXA.CAREERS.HIBOB.COM")
|
||||
for host in ("careers.hibob.com", "other.careers.hibob.com", "dixa.hibob.com",
|
||||
|
||||
Reference in new issue
Block a user