Read a Phenom role's description from the page state when the page has no JobPosting, and fail a page with neither
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f0db38393
commit
cf182ad921
3 files changed
+77
-17
No files matched your search
@@ -198,11 +198,33 @@ def test_detail_finds_the_job_posting_among_other_blocks_and_takes_its_date() ->
|
||||
assert got["posted"].isoformat() == "2026-09-08T00:00:00+00:00"
|
||||
|
||||
|
||||
def test_detail_of_a_page_without_a_posting_has_nothing_to_read() -> None:
|
||||
def test_detail_falls_back_to_the_page_state_where_there_is_no_job_posting() -> None:
|
||||
"""King's pages of roles posted that day had no `JobPosting` block, only a
|
||||
`WebPage` one, and the role in the state the page assigns to `phApp.ddo`."""
|
||||
row = _rows()[0]
|
||||
got = phenom.detail(_get_of("phenom-detail-3.html", []), SLUG, row)
|
||||
assert got["description"].startswith("Craft: Games Design & Production Job Description:")
|
||||
assert "<" not in got["description"] and "&" not in got["description"]
|
||||
assert got["remote"] == "onsite"
|
||||
assert "posted" not in got and set(got) <= set(ats.DETAIL_FIELDS)
|
||||
|
||||
|
||||
def test_detail_of_a_page_with_no_description_fails_so_that_it_is_asked_again() -> None:
|
||||
def get(url: str, **kwargs: Any) -> bytes:
|
||||
return (b'<html><script type="application/ld+json">{"@type": "BreadcrumbList"}</script>'
|
||||
b'<script type="application/ld+json">{broken</script></html>')
|
||||
assert phenom.detail(get, SLUG, {"url": "https://careers.king.com/us/en/job/1"}) == {}
|
||||
b'<script type="application/ld+json">{broken</script>'
|
||||
b'<script>phApp.ddo = {"jobDetail": {"data": {"job": {"title": "x"}}}};</script></html>')
|
||||
with pytest.raises(ValueError, match="no description"):
|
||||
phenom.detail(get, SLUG, {"url": "https://careers.king.com/us/en/job/1"})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("state", ["", "phApp.ddo = {broken", 'phApp.ddo = {"jobDetail": []};',
|
||||
'phApp.ddo = {"siteConfig": {}};'])
|
||||
def test_a_page_state_that_is_not_a_role_is_no_description(state: str) -> None:
|
||||
def get(url: str, **kwargs: Any) -> bytes:
|
||||
return f"<html><script>{state}</script></html>".encode()
|
||||
with pytest.raises(ValueError, match="no description"):
|
||||
phenom.detail(get, SLUG, {"url": "https://careers.king.com/us/en/job/1"})
|
||||
|
||||
|
||||
# ----------------------------------------------------------- slug and URLs
|
||||
|
||||
Reference in new issue
Block a user