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
+27
-25
@@ -3,13 +3,11 @@ answers. No network."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -18,7 +16,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 gem # noqa: E402
|
||||
from plugins.readers import Ask, gem # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
API = "https://jobs.gem.com/api/public/graphql"
|
||||
@@ -47,7 +45,7 @@ def _listing() -> dict[str, bytes | Exception]:
|
||||
|
||||
def test_a_listing_becomes_rows() -> None:
|
||||
asked: list[dict[str, Any]] = []
|
||||
decoded, results, total, cursor = gem.page(_get_of(_listing(), asked), "productboard", None)
|
||||
decoded, results, total, cursor = gem.page(_get_of(_listing(), asked), "productboard", None, Ask())
|
||||
assert asked == [{"operationName": "JobBoardList", "variables": {"boardId": "productboard"},
|
||||
"query": gem.LIST_QUERY, "headers": None}]
|
||||
assert (total, cursor) == (None, None) and len(results) == 11
|
||||
@@ -62,6 +60,11 @@ def test_a_listing_becomes_rows() -> None:
|
||||
assert (first["posted"], first["description"], first["salary_text"]) == (None, "", "")
|
||||
assert backend["source_id"] == "am9icG9zdDqWC1V_RM7U6ORvTd1Iu64r" # opaque
|
||||
assert backend["location"] == "Prague; Remote Europe; Brno"
|
||||
# Every place is kept, and the host's own flag says which is remote.
|
||||
assert backend["places"] == [{"text": "Prague", "remote": False},
|
||||
{"text": "Remote Europe", "remote": True},
|
||||
{"text": "Brno", "remote": False}]
|
||||
assert first["employment"] == "full_time"
|
||||
assert len({r["source_id"] for r in rows}) == 11
|
||||
|
||||
|
||||
@@ -80,28 +83,28 @@ def test_a_posting_without_a_title_or_an_ext_id_is_left_out() -> None:
|
||||
assert gem.rows([{"extId": "1", "title": " "}, {"extId": "", "title": "Role"}], "acme") == []
|
||||
|
||||
|
||||
def test_the_board_is_read_through_the_app_without_origin_or_referer() -> None:
|
||||
seen: list[httpx.Request] = []
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
seen.append(request)
|
||||
return httpx.Response(200, content=_read("gem.json"))
|
||||
|
||||
with httpx.Client(transport=httpx.MockTransport(handler)) as client:
|
||||
rows, complete = ats._fetch_rows(client, "gem:productboard")
|
||||
assert len(rows) == 11 and complete
|
||||
(request,) = seen
|
||||
assert str(request.url) == API and request.method == "POST"
|
||||
assert json.loads(request.content)["variables"] == {"boardId": "productboard"}
|
||||
assert "origin" not in request.headers and "referer" not in request.headers
|
||||
assert request.headers["content-type"] == "application/json"
|
||||
def test_the_board_is_one_post_without_origin_or_referer() -> None:
|
||||
asked: list[dict[str, Any]] = []
|
||||
decoded, _results, total, cursor = gem.page(_get_of(_listing(), asked), "productboard",
|
||||
None, Ask())
|
||||
(call,) = asked
|
||||
assert call["variables"] == {"boardId": "productboard"} and call["headers"] is None
|
||||
assert len(gem.rows(decoded, "productboard")) == 11 and (total, cursor) == (None, None)
|
||||
|
||||
|
||||
def test_an_empty_board_is_complete_at_zero() -> None:
|
||||
def test_an_empty_board_is_no_rows() -> None:
|
||||
body = b'{"data":{"oatsExternalJobPostings":{"jobPostings":[]}}}'
|
||||
with httpx.Client(transport=httpx.MockTransport(
|
||||
lambda request: httpx.Response(200, content=body))) as client:
|
||||
assert ats._fetch_rows(client, "gem:nobody") == ([], True)
|
||||
decoded, results, _total, cursor = gem.page(
|
||||
_get_of({"JobBoardList": body}, []), "nobody", None, Ask())
|
||||
assert gem.rows(decoded, "nobody") == [] and results == [] and cursor is None
|
||||
|
||||
|
||||
def test_it_declares_one_page_that_may_be_empty_by_mistake() -> None:
|
||||
reads = gem.READS
|
||||
assert (reads.listing, reads.text, reads.places, reads.empty) == (
|
||||
"paged", "detail", "many", "suspect")
|
||||
assert reads.robots.startswith("read: robots.txt allows /<board>")
|
||||
assert not hasattr(gem, "robots_page")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("body", "message"), [
|
||||
@@ -114,7 +117,7 @@ def test_an_empty_board_is_complete_at_zero() -> None:
|
||||
])
|
||||
def test_an_answer_of_another_shape_fails_with_a_clear_error(body: bytes, message: str) -> None:
|
||||
with pytest.raises(ValueError, match=message):
|
||||
gem.page(_get_of({"JobBoardList": body}, []), "productboard", None)
|
||||
gem.page(_get_of({"JobBoardList": body}, []), "productboard", None, Ask())
|
||||
|
||||
|
||||
def test_detail_reads_the_text_and_the_date() -> None:
|
||||
@@ -149,7 +152,6 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
for slug in ("productboard", "Productboard", "senndertechnologies-gmbh", "a_b", "1"):
|
||||
assert gem.slug_ok(slug)
|
||||
assert gem.careers_url("Productboard") == "https://jobs.gem.com/Productboard"
|
||||
assert gem.robots_page("productboard") == "https://jobs.gem.com/productboard"
|
||||
allow = gem.allowed("productboard")
|
||||
assert allow("jobs.gem.com") and allow("JOBS.gem.com")
|
||||
assert not allow("gem.com") and not allow("productboard.gem.com")
|
||||
|
||||
Reference in new issue
Block a user