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
+46
-43
@@ -8,16 +8,16 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app import models as app_models # noqa: E402
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import jobylon # noqa: E402
|
||||
from plugins.readers import Ask, jobylon # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
BOARD = (FIXTURES / "jobylon.html").read_bytes()
|
||||
@@ -34,6 +34,7 @@ def test_rows_come_from_the_embeds_literal() -> None:
|
||||
assert first["title"] == "Financial Controller"
|
||||
assert first["url"] == ROLE
|
||||
assert first["location"] == "Stockholm"
|
||||
assert first["places"] == [{"text": "Stockholm", "remote": None}]
|
||||
assert first["department"] == "Accounting & Finance" # `&` read as `&`
|
||||
assert first["remote"] == "hybrid"
|
||||
assert first["description"] == "" and first["salary_text"] == ""
|
||||
@@ -45,6 +46,7 @@ def test_rows_come_from_the_embeds_literal() -> None:
|
||||
def test_places_department_and_remote_follow_the_embeds_words() -> None:
|
||||
rows = {r["source_id"]: r for r in jobylon.parse(BOARD, "3143")}
|
||||
assert rows["384238"]["location"] == "Houston; Dallas; Atlanta"
|
||||
assert [p["text"] for p in rows["384238"]["places"]] == ["Houston", "Dallas", "Atlanta"]
|
||||
assert rows["384238"]["department"] == "" # "All functions" names none
|
||||
assert rows["382124"]["remote"] == "remote"
|
||||
assert rows["382860"]["remote"] == "onsite"
|
||||
@@ -90,7 +92,8 @@ def test_detail_reads_the_role_pages_json_ld() -> None:
|
||||
ROLE_2: (FIXTURES / "jobylon-role-2.html").read_bytes()}
|
||||
first = jobylon.detail(_get(pages, asked), "3143", rows["385191"])
|
||||
assert asked == [ROLE]
|
||||
assert set(first) <= set(ats.DETAIL_FIELDS)
|
||||
assert set(first) <= set(ats.DETAIL_FIELDS) | {"places"}
|
||||
assert first["places"] == [{"text": "Stockholm, Sweden", "remote": None}]
|
||||
assert first["description"].startswith("Want to be part of transforming road freight?")
|
||||
assert "<" not in first["description"] and "world's leading" in first["description"]
|
||||
assert first["posted"] is not None and first["posted"].isoformat() == \
|
||||
@@ -99,6 +102,7 @@ def test_detail_reads_the_role_pages_json_ld() -> None:
|
||||
# All four places, where the embed named three.
|
||||
second = jobylon.detail(_get(pages), "3143", rows["384238"])
|
||||
assert second["location"] == "Houston, TX, USA; Dallas, TX, USA; New Jersey, USA; Atlanta, GA, USA"
|
||||
assert len(second["places"]) == 4
|
||||
|
||||
|
||||
def test_detail_without_a_job_posting_fails_the_read() -> None:
|
||||
@@ -111,48 +115,48 @@ def test_detail_without_a_job_posting_fails_the_read() -> None:
|
||||
jobylon.detail(_get({ROLE: page}), "3143", row)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def web(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]:
|
||||
answers: dict[str, Any] = {}
|
||||
def test_the_board_is_one_request_and_each_role_is_read_on_its_own_page() -> None:
|
||||
asked: list[str] = []
|
||||
|
||||
def fake_get(client, url, host, slug, *, method="GET", payload=None, headers=None,
|
||||
www_twin=False):
|
||||
asked.append(url)
|
||||
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
|
||||
|
||||
monkeypatch.setattr(ats, "_get", fake_get)
|
||||
monkeypatch.setattr(ats, "PAGE_DELAY", 0)
|
||||
return {"answers": answers, "asked": asked}
|
||||
pages = {FEED: BOARD, ROLE: (FIXTURES / "jobylon-role.html").read_bytes(),
|
||||
ROLE_2: (FIXTURES / "jobylon-role-2.html").read_bytes()}
|
||||
get = _get(pages, asked)
|
||||
rows = jobylon.parse(get(jobylon.feed_url("3143", Ask())), "3143")
|
||||
assert len(rows) == 5 and asked == [FEED]
|
||||
found = jobylon.detail(get, "3143", rows[0])
|
||||
assert asked == [FEED, ROLE] and found["description"].startswith("Want to be part")
|
||||
|
||||
|
||||
def test_the_board_is_one_request_and_each_role_is_read_once(web: dict[str, Any]) -> None:
|
||||
web["answers"] |= {FEED: BOARD, ROLE: (FIXTURES / "jobylon-role.html").read_bytes(),
|
||||
ROLE_2: (FIXTURES / "jobylon-role-2.html").read_bytes()}
|
||||
with httpx.Client() as client:
|
||||
rows, complete = ats._fetch_rows(client, "jobylon:3143")
|
||||
assert len(rows) == 5 and complete and web["asked"] == [FEED]
|
||||
# The three roles whose pages are not saved answer 404, which counts as read.
|
||||
for row in rows:
|
||||
web["answers"].setdefault(row["url"], httpx.HTTPStatusError(
|
||||
"404", request=httpx.Request("GET", row["url"]),
|
||||
response=httpx.Response(404, request=httpx.Request("GET", row["url"]))))
|
||||
filled, done, failed = ats._read_details(client, "jobylon:3143", rows, complete,
|
||||
set(), set())
|
||||
assert done == {f"jobylon:3143:{r['source_id']}" for r in rows} and not failed
|
||||
assert filled[0]["description"].startswith("Want to be part") and filled[0]["location"]
|
||||
assert filled[2]["description"] == ""
|
||||
def test_an_empty_board_is_no_roles() -> None:
|
||||
assert jobylon.parse(EMPTY, "1056") == []
|
||||
|
||||
|
||||
def test_an_empty_board_is_complete(web: dict[str, Any]) -> None:
|
||||
web["answers"]["https://cdn.jobylon.com/jobs/companies/1056/embed/v2/"] = EMPTY
|
||||
with httpx.Client() as client:
|
||||
assert ats._fetch_rows(client, "jobylon:1056") == ([], True)
|
||||
def test_the_experience_is_mapped_and_a_word_the_table_lacks_is_logged(
|
||||
caplog: pytest.LogCaptureFixture) -> None:
|
||||
caplog.set_level("DEBUG", logger="plugins.readers.jobylon")
|
||||
rows = {r["source_id"]: r for r in jobylon.parse(BOARD, "3143")}
|
||||
assert rows["384238"]["seniority"] == "mid" # "Mid level"
|
||||
assert "seniority" not in rows["385191"] # "Experienced" says too little
|
||||
assert "unknown experience 'Experienced'" in caplog.text
|
||||
assert rows["385191"]["employment"] == "full_time"
|
||||
assert all(r.get("seniority", "mid") in app_models.SENIORITIES for r in rows.values())
|
||||
rows = {r["source_id"]: r for r in jobylon.parse(
|
||||
(FIXTURES / "jobylon-places.html").read_bytes(), "3143")}
|
||||
assert rows["502"]["seniority"] == "intern" and rows["502"]["employment"] == "intern"
|
||||
|
||||
|
||||
def test_a_summary_is_the_teaser_unless_the_embed_says_none() -> None:
|
||||
(row,) = jobylon.parse((FIXTURES / "jobylon-teaser.html").read_bytes(), "3143")
|
||||
assert row["teaser"] == "Lead our Houston depot and its 40 drivers."
|
||||
assert all("teaser" not in r for r in jobylon.parse(BOARD, "3143"))
|
||||
|
||||
|
||||
def test_it_declares_a_whole_listing_with_a_teaser_and_detail() -> None:
|
||||
reads = jobylon.READS
|
||||
assert (reads.listing, reads.text, reads.teaser, reads.places) == (
|
||||
"whole", "detail", True, "many")
|
||||
assert (reads.fields.posted, reads.fields.seniority) == ("trusted", "stated")
|
||||
assert reads.robots.startswith("read: robots.txt allows /jobs/companies/")
|
||||
assert not hasattr(jobylon, "robots_page")
|
||||
|
||||
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
@@ -163,10 +167,9 @@ def test_the_module_is_registered_as_a_feed_host_with_detail() -> None:
|
||||
assert hasattr(jobylon, "detail") and not hasattr(jobylon, "page")
|
||||
|
||||
|
||||
def test_the_urls_and_the_robots_page() -> None:
|
||||
assert jobylon.feed_url("3143") == FEED
|
||||
def test_the_urls() -> None:
|
||||
assert jobylon.feed_url("3143", Ask()) == FEED
|
||||
assert jobylon.careers_url("3143") == "https://emp.jobylon.com/companies/3143/"
|
||||
assert jobylon.robots_page("3143") == FEED
|
||||
allow = jobylon.allowed("3143")
|
||||
assert allow("cdn.jobylon.com") and allow("emp.jobylon.com") and allow("EMP.JOBYLON.COM")
|
||||
for host in ("jobylon.com", "feed.jobylon.com", "emp.jobylon.com.evil.example",
|
||||
|
||||
Reference in new issue
Block a user