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
+41
-23
@@ -18,7 +18,7 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import eightfold # noqa: E402
|
||||
from plugins.readers import Ask, eightfold # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
SLUG = "jobs.ericsson.com/ericsson.com"
|
||||
@@ -47,6 +47,26 @@ def _search(total: int, seen: list[str] | None = None) -> httpx.MockTransport:
|
||||
return httpx.MockTransport(handler)
|
||||
|
||||
|
||||
def _crawl(slug: str, transport: httpx.MockTransport) -> tuple[list[dict[str, Any]], bool]:
|
||||
"""What the runner does with a paged reader: pages until the cursor ends,
|
||||
complete when as many distinct ids were read as the host stated."""
|
||||
rows: list[dict[str, Any]] = []
|
||||
ids: set[str] = set()
|
||||
total: Any = None
|
||||
with httpx.Client(transport=transport) as client:
|
||||
def get(url: str, **_: Any) -> bytes:
|
||||
return client.get(url).content
|
||||
|
||||
cursor: Any = None
|
||||
while True:
|
||||
decoded, results, total, cursor = eightfold.page(get, slug, cursor, Ask())
|
||||
rows += eightfold.rows(decoded, slug)
|
||||
ids |= {r["id"] for r in results}
|
||||
if cursor is None or (total is not None and len(ids) >= total):
|
||||
break
|
||||
return rows, total is not None and len(ids) >= total
|
||||
|
||||
|
||||
def test_a_page_becomes_rows() -> None:
|
||||
rows = eightfold.rows(_saved()["data"]["positions"], SLUG)
|
||||
assert len(rows) == 5
|
||||
@@ -56,11 +76,14 @@ def test_a_page_becomes_rows() -> None:
|
||||
assert first["url"] == "https://jobs.ericsson.com/careers/job/563121777024688"
|
||||
assert first["location"] == "Stockholm, Sweden" # the city is its own region
|
||||
assert first["department"] == "76 Product Development"
|
||||
assert first["posted"] == datetime.fromtimestamp(1790703782, tz=UTC)
|
||||
# `creationTs`, the posting date; `postedTs` (1790703782) is refreshed in bulk.
|
||||
assert first["posted"] == datetime.fromtimestamp(1785822052, tz=UTC)
|
||||
assert first["places"] == [{"text": "Stockholm, Sweden", "remote": None}]
|
||||
assert first["remote"] == "onsite" and (first["description"], first["salary_text"]) == ("", "")
|
||||
assert mexico["location"] == "Mexico City, Mexico"
|
||||
assert many["location"] == ("Tecnoparque, Mexico City, Mexico; Santa Fe, Mexico City, Mexico; "
|
||||
"Mexico City, Mexico; Tlalnepantla, Estado de México, Mexico")
|
||||
assert [p["text"] for p in many["places"]] == many["location"].split("; ")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("option", "remote"), [
|
||||
@@ -89,36 +112,23 @@ def test_a_page_asks_for_the_newest_first_from_its_offset() -> None:
|
||||
asked.append(url)
|
||||
return json.dumps(_saved()).encode()
|
||||
|
||||
decoded, results, total, cursor = eightfold.page(get, SLUG, None)
|
||||
decoded, results, total, cursor = eightfold.page(get, SLUG, None, Ask())
|
||||
assert asked == ["https://jobs.ericsson.com/api/pcsx/search?domain=ericsson.com"
|
||||
"&sort_by=timestamp&start=0"]
|
||||
assert (len(decoded), len(results), total, cursor) == (5, 5, 637, 5)
|
||||
assert eightfold.page(get, SLUG, 630)[3] == 635
|
||||
assert eightfold.page(get, SLUG, 630, Ask())[3] == 635
|
||||
assert asked[-1].endswith("&start=630")
|
||||
|
||||
|
||||
def test_a_board_is_read_ten_at_a_time_to_its_total(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(ats, "PAGE_DELAY", 0)
|
||||
def test_a_board_is_read_ten_at_a_time_to_its_total() -> None:
|
||||
seen: list[str] = []
|
||||
with httpx.Client(transport=_search(25, seen)) as client:
|
||||
rows, complete = ats._fetch_rows(client, f"eightfold:{SLUG}")
|
||||
rows, complete = _crawl(SLUG, _search(25, seen))
|
||||
assert (len(rows), complete) == (25, True)
|
||||
assert [u.rsplit("=", 1)[1] for u in seen] == ["0", "10", "20"]
|
||||
|
||||
|
||||
def test_a_board_over_the_page_cap_is_incomplete(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""The cap is 100 pages of ten: a board of 1,292 (Infineon's) or 2,319
|
||||
(Microsoft's) is read as its first thousand and never as the whole."""
|
||||
monkeypatch.setattr(ats, "PAGE_DELAY", 0)
|
||||
seen: list[str] = []
|
||||
with httpx.Client(transport=_search(1292, seen)) as client:
|
||||
rows, complete = ats._fetch_rows(client, "eightfold:infineon.eightfold.ai/infineon.com")
|
||||
assert (len(rows), complete) == (1000, False) and len(seen) == ats.MAX_PAGES == 100
|
||||
|
||||
|
||||
def test_an_empty_board_is_complete_at_zero(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
with httpx.Client(transport=_search(0)) as client:
|
||||
assert ats._fetch_rows(client, f"eightfold:{SLUG}") == ([], True)
|
||||
def test_an_empty_board_is_complete_at_zero() -> None:
|
||||
assert _crawl(SLUG, _search(0)) == ([], True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("body", [
|
||||
@@ -126,7 +136,7 @@ def test_an_empty_board_is_complete_at_zero(monkeypatch: pytest.MonkeyPatch) ->
|
||||
b'{"data": {"positions": null}}'])
|
||||
def test_an_answer_that_is_not_a_search_raises(body: bytes) -> None:
|
||||
with pytest.raises(ValueError):
|
||||
eightfold.page(lambda url, **_: body, SLUG, None)
|
||||
eightfold.page(lambda url, **_: body, SLUG, None, Ask())
|
||||
|
||||
|
||||
def test_detail_reads_the_text_of_the_ad() -> None:
|
||||
@@ -164,7 +174,6 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
for slug in (SLUG, "infineon.eightfold.ai/infineon.com", "Apply.Careers.Microsoft.com/microsoft.com"):
|
||||
assert eightfold.slug_ok(slug) and ats.is_known_target(f"eightfold:{slug}")
|
||||
assert eightfold.careers_url("Jobs.Ericsson.com/ericsson.com") == "https://jobs.ericsson.com/careers"
|
||||
assert eightfold.robots_page(SLUG) == "https://jobs.ericsson.com/careers"
|
||||
allow = eightfold.allowed("Jobs.Ericsson.com/ericsson.com")
|
||||
assert allow("jobs.ericsson.com") and allow("JOBS.ERICSSON.COM")
|
||||
assert not allow("ericsson.com") and not allow("evil.example")
|
||||
@@ -193,3 +202,12 @@ def test_discovery_reads_the_host_and_domain_from_a_link_that_has_both() -> None
|
||||
assert ("eightfold", "infineon.eightfold.ai/infineon.com") in found
|
||||
assert ("eightfold", "") in found
|
||||
assert "eightfold" not in {h for h, _ in discover._UNREADABLE if h not in readers.HOSTS}
|
||||
|
||||
|
||||
def test_it_declares_a_paged_read_of_ten_with_a_total_and_no_filter_yet() -> None:
|
||||
reads = eightfold.READS
|
||||
assert (reads.listing, reads.page_size, reads.text, reads.complete, reads.places) == (
|
||||
"paged", 10, "detail", "stated", "many")
|
||||
assert reads.filters.declared() == {} and reads.fields.posted == "listed"
|
||||
assert reads.robots.startswith("read: robots.txt allows /careers")
|
||||
assert not hasattr(eightfold, "robots_page")
|
||||
Reference in new issue
Block a user