Files
jobboard/tests/test_ats_workday.py
T
WolfandClaude Opus 5.5 73dec9028e Rename plugins/atshosts to plugins/readers
Every import, test and live doc follows the new path; behaviour is unchanged.
tests/test_atshosts.py becomes tests/test_readers.py. plan-readers.md and
review-ingest.md keep the old name, since they describe the state before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 08:48:30 +02:00

534 lines
25 KiB
Python

"""The Workday host module: rows from saved listings, the paging quirks of a
tenant's list endpoint against a fake `get`, `detail` from saved responses,
the slug and its allow-list, robots.txt and discovery's patterns. No network
-- every answer is a file under `tests/fixtures/ats/` or written here."""
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]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from app.jobs import discover # noqa: E402
from plugins import ats # noqa: E402
from plugins.readers import workday # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
SLUG = "zendesk.wd1/zendesk"
HOST = "zendesk.wd1.myworkdayjobs.com"
TODAY = datetime(2026, 9, 29, tzinfo=UTC)
def _load(name: str) -> Any:
return json.loads((FIXTURES / name).read_text())
@pytest.fixture(autouse=True)
def _frozen_today(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(workday, "_today", lambda: TODAY)
@pytest.fixture
def no_delay(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(ats, "PAGE_DELAY", 0)
# ------------------------------------------------------------------- rows
def test_rows_read_the_listing_of_a_tenant_that_sends_remote_type() -> None:
rows = workday.rows(_load("workday.json"), SLUG)
assert [r["source_id"] for r in rows] == ["R35358", "R35239", "R35277", "R35551", "R35544"]
first = rows[0]
assert first["title"] == "Associate Solutions Architect"
assert first["location"] == "Remote, Mexico City, Mexico"
assert first["url"] == (f"https://{HOST}/zendesk/job/Remote-Mexico-City-Mexico/"
"Associate-Solutions-Architect_R35358")
assert first["posted"] == TODAY
assert first["description"] == "" and first["department"] == "" and first["salary_text"] == ""
# "Fully Flexible" is Zendesk's word for remote.
assert [r["remote"] for r in rows] == ["remote", "onsite", "hybrid", "remote", "hybrid"]
def test_rows_of_a_tenant_without_remote_type_leave_remote_unknown() -> None:
rows = workday.rows(_load("workday-saxo.json"), "saxobank.wd3/CareeratSaxoBank")
assert [r["source_id"] for r in rows] == [
"R-19507", "R-19142", "R-19427", "R-19402", "R-19359"]
assert all(r["remote"] is None for r in rows)
assert rows[0]["url"] == ("https://saxobank.wd3.myworkdayjobs.com/CareeratSaxoBank"
"/job/Singapore/Client-Support-and-Sales---Singapore_R-19507")
# Yesterday, and four days ago.
assert rows[0]["posted"] == datetime(2026, 9, 28, tzinfo=UTC)
assert rows[2]["posted"] == datetime(2026, 9, 25, tzinfo=UTC)
def test_rows_of_a_site_called_jobs_state_the_requisition_id_and_no_date_past_30_days() -> None:
rows = workday.rows(_load("workday-redhat.json"), "redhat.wd5/jobs")
assert [r["source_id"] for r in rows] == [
"R-059377", "R-058740", "R-059566", "R-058743"] # not the reposts' "-1" and "-2"
assert rows[2]["location"] == "2 Locations"
assert rows[2]["url"].startswith("https://redhat.wd5.myworkdayjobs.com/jobs/job/")
assert rows[3]["posted"] is None # "Posted 30+ Days Ago" says only that it is older
assert [r["remote"] for r in rows] == ["onsite", "remote", "remote", "hybrid"]
@pytest.mark.parametrize(("text", "expected"), [
("Posted Today", datetime(2026, 9, 29, tzinfo=UTC)),
("Posted Yesterday", datetime(2026, 9, 28, tzinfo=UTC)),
("Posted 1 Day Ago", datetime(2026, 9, 28, tzinfo=UTC)),
("Posted 21 Days Ago", datetime(2026, 9, 8, tzinfo=UTC)),
("Posted 30+ Days Ago", None),
("Vor 3 Tagen veroeffentlicht", None),
("", None),
])
def test_posted_is_read_only_where_the_text_is_exact(text: str, expected: datetime | None) -> None:
assert workday._posted(text) == expected
def test_a_posting_without_a_title_or_a_path_is_skipped() -> None:
page = {"jobPostings": [
{"bulletFields": ["0000036369"]}, # LEGO's, no title
{"title": "No path", "bulletFields": ["R1"]},
{"externalPath": "/job/X/y_R2", "bulletFields": ["R2"]}, # no title
{"title": " ", "externalPath": "/job/X/y_R3"},
{"title": "Whole", "externalPath": "/job/X/Whole_R4", "locationsText": "X",
"postedOn": "Posted Today", "bulletFields": ["R4"]},
]}
assert [r["title"] for r in workday.rows(page, SLUG)] == ["Whole"]
def test_the_id_is_the_path_where_the_requisition_id_is_not_in_it() -> None:
"""`bulletFields` sometimes lead with something else, a location."""
page = {"jobPostings": [
{"title": "A", "externalPath": "/job/Oslo/A_R1", "bulletFields": ["Oslo"]},
{"title": "B", "externalPath": "/job/Oslo/B_R2"},
{"title": "C", "externalPath": "/job/Oslo/C_R3-1", "bulletFields": ["R3", "Oslo"]}]}
assert [r["source_id"] for r in workday.rows(page, SLUG)] == [
"/job/Oslo/A_R1", "/job/Oslo/B_R2", "R3"]
# ----------------------------------------------------------------- paging
def _list_page(total: int, start: int, count: int, *, path_less: int | None = None
) -> bytes:
postings: list[dict[str, Any]] = []
for n in range(start, min(start + count, total)):
if n == path_less:
postings.append({"bulletFields": [f"P{n}"]})
else:
postings.append({"title": f"Role {n}", "externalPath": f"/job/Oslo/Role-{n}_R{n}",
"locationsText": "Oslo", "postedOn": "Posted Today",
"bulletFields": [f"R{n}"]})
return json.dumps({"total": total, "jobPostings": postings}).encode()
class Tenant:
"""A tenant's list endpoint with the quirks of the real ones: `total` on
the first page only (`0` after it), and an offset past the end answered
with the first page again rather than an empty one."""
def __init__(self, total: int, *, path_less: int | None = None,
repeat_total: bool = False) -> None:
self.total, self.path_less, self.repeat_total = total, path_less, repeat_total
self.calls: list[tuple[str, str, Any]] = []
def __call__(self, client: Any, url: str, host: str, slug: str, *,
method: str = "GET", payload: dict[str, Any] | None = None,
headers: dict[str, str] | None = None) -> bytes:
self.calls.append((method, url, payload))
assert payload is not None
offset = payload["offset"]
if offset >= self.total:
offset = 0
body = json.loads(_list_page(self.total, offset, payload["limit"],
path_less=self.path_less))
if payload["offset"] and not self.repeat_total:
body["total"] = 0
return json.dumps(body).encode()
def test_a_board_is_read_page_by_page_to_its_total_and_is_complete(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
tenant = Tenant(45)
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert complete and len(rows) == 45
assert [c[2]["offset"] for c in tenant.calls] == [0, 20, 40]
def test_the_post_body_and_url_are_what_the_tenant_expects(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
tenant = Tenant(25)
monkeypatch.setattr(ats, "_get", tenant)
ats._fetch_rows(object(), "workday:lego.wd103/LEGO_External") # type: ignore[arg-type]
url = "https://lego.wd103.myworkdayjobs.com/wday/cxs/lego/LEGO_External/jobs"
body = {"appliedFacets": {}, "limit": 20, "searchText": ""}
assert tenant.calls == [("POST", url, body | {"offset": 0}),
("POST", url, body | {"offset": 20})]
def test_the_total_is_kept_from_the_first_page_though_later_ones_state_none_or_zero(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
for repeat in (False, True):
tenant = Tenant(41, repeat_total=repeat)
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert (len(rows), complete, len(tenant.calls)) == (41, True, 3)
def test_the_read_stops_at_the_total_and_never_asks_past_the_end(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
"""Past the end the host answers the first page again, which is never
empty: a read that waited for an empty page would run to `MAX_PAGES`."""
tenant = Tenant(40)
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert (len(rows), complete) == (40, True)
assert [c[2]["offset"] for c in tenant.calls] == [0, 20]
def test_a_page_wrapping_to_the_first_one_leaves_the_board_incomplete(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
"""The first page states 60, the tenant holds 40: the third page is the
first again, adds nothing, and ends the read short of the total."""
real = Tenant(40)
def tenant(client: Any, url: str, host: str, slug: str, *,
method: str = "GET", payload: dict[str, Any] | None = None,
headers: dict[str, str] | None = None) -> bytes:
body = json.loads(real(client, url, host, slug, method=method, payload=payload))
if payload and payload["offset"] == 0:
body["total"] = 60
return json.dumps(body).encode()
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert (len(rows), complete) == (40, False)
def test_a_posting_without_a_title_still_counts_toward_the_total(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
"""LEGO lists 453 postings of which one has no title and no path: 452 rows,
and the board is complete all the same."""
tenant = Tenant(45, path_less=7)
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert (len(rows), complete) == (44, True)
def test_an_empty_site_is_complete_at_zero(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
tenant = Tenant(0)
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert (rows, complete, len(tenant.calls)) == ([], True, 1)
def test_a_first_page_stating_no_total_is_read_to_a_page_that_adds_nothing(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
real = Tenant(30)
def tenant(client: Any, url: str, host: str, slug: str, *,
method: str = "GET", payload: dict[str, Any] | None = None,
headers: dict[str, str] | None = None) -> bytes:
body = json.loads(real(client, url, host, slug, method=method, payload=payload))
body.pop("total")
return json.dumps(body).encode()
monkeypatch.setattr(ats, "_get", tenant)
rows, complete = ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
assert len(rows) == 30 and not complete
def test_a_page_that_is_not_json_fails_the_read(
monkeypatch: pytest.MonkeyPatch, no_delay: None) -> None:
monkeypatch.setattr(ats, "_get", lambda *a, **k: b"<html>maintenance</html>")
with pytest.raises(ValueError):
ats._fetch_rows(object(), f"workday:{SLUG}") # type: ignore[arg-type]
# ----------------------------------------------------------------- detail
def _get_of(answer: bytes, asked: list[str]) -> Any:
def get(url: str, *, method: str = "GET", payload: Any = None, headers: Any = None) -> bytes:
asked.append(url)
assert method == "GET"
return answer
return get
def test_detail_reads_the_description_date_remote_and_place_of_the_role() -> None:
row = workday.rows(_load("workday.json"), SLUG)[0]
asked: list[str] = []
got = workday.detail(_get_of((FIXTURES / "workday-detail.json").read_bytes(), asked),
SLUG, row)
assert asked == [f"https://{HOST}/wday/cxs/zendesk/zendesk"
"/job/Remote-Mexico-City-Mexico/Associate-Solutions-Architect_R35358"]
assert set(got) <= set(ats.DETAIL_FIELDS)
assert set(got) == {"description", "location", "posted", "remote"}
assert got["posted"] == datetime(2026, 9, 29, tzinfo=UTC)
assert got["remote"] == "remote"
assert got["location"] == "Remote, Mexico City, Mexico"
assert got["description"].startswith("Job Description") or len(got["description"]) > 200
assert "<" not in got["description"] and "&nbsp;" not in got["description"]
assert " " not in got["description"]
def test_detail_names_every_location_of_a_role_listed_as_several() -> None:
row = workday.rows(_load("workday-redhat.json"), "redhat.wd5/jobs")[2]
asked: list[str] = []
got = workday.detail(_get_of((FIXTURES / "workday-redhat-detail.json").read_bytes(), asked),
"redhat.wd5/jobs", row)
assert asked == ["https://redhat.wd5.myworkdayjobs.com/wday/cxs/redhat/jobs"
"/job/Remote-Italy/Telco-Cloud-Consultant_R-059566-2"]
assert got["location"] == "Remote Italy; Remote Spain"
def _detail(**info: Any) -> bytes:
return json.dumps({"jobPostingInfo": {"title": "T", **info}}).encode()
def test_detail_of_a_tenant_without_remote_type_leaves_it_out() -> None:
row = workday.rows(_load("workday-saxo.json"), "saxobank.wd3/CareeratSaxoBank")[0]
got = workday.detail(
_get_of(_detail(jobDescription="<p>Trade &amp; settle</p>", location="Singapore",
startDate="2026-09-28"), []),
"saxobank.wd3/CareeratSaxoBank", row)
assert got == {"description": "Trade & settle", "location": "Singapore",
"posted": datetime(2026, 9, 28, tzinfo=UTC)}
def test_detail_adds_the_country_to_a_place_that_does_not_name_it() -> None:
row = workday.rows(_load("workday.json"), SLUG)[0]
got = workday.detail(
_get_of(_detail(location="Billund", country={"descriptor": "Denmark"}), []), SLUG, row)
assert got == {"location": "Billund, Denmark"}
def test_detail_takes_no_word_for_remote_it_does_not_know() -> None:
row = workday.rows(_load("workday.json"), SLUG)[0]
assert "remote" not in workday.detail(_get_of(_detail(remoteType="No"), []), SLUG, row)
def test_detail_refuses_a_row_that_is_not_a_role_of_the_board() -> None:
asked: list[str] = []
for url in ("https://evil.example/zendesk/job/x_R1",
f"https://{HOST}/other/job/x_R1",
f"https://{HOST}/zendesk/job/../../x",
f"https://{HOST}/zendesk", f"https://{HOST}/zendesk/job/x?y=1", ""):
with pytest.raises(ValueError):
workday.detail(_get_of(b"{}", asked), SLUG, {"url": url})
assert asked == []
def test_detail_refuses_an_answer_that_is_not_a_role() -> None:
row = workday.rows(_load("workday.json"), SLUG)[0]
with pytest.raises(ValueError, match="jobPostingInfo"):
workday.detail(_get_of(b'{"errorCode": "S21"}', []), SLUG, row)
def test_detail_lets_a_404_through_for_the_shared_code_to_count_as_read() -> None:
row = workday.rows(_load("workday.json"), SLUG)[0]
request = httpx.Request("GET", f"https://{HOST}/")
def get(url: str, **kwargs: Any) -> bytes:
raise httpx.HTTPStatusError("404", request=request,
response=httpx.Response(404, request=request))
with pytest.raises(httpx.HTTPStatusError):
workday.detail(get, SLUG, row)
def test_detail_is_read_through_the_getter_ats_binds(
monkeypatch: pytest.MonkeyPatch) -> None:
seen: list[tuple[str, str, str]] = []
def fake_get(client: Any, url: str, host: str, slug: str, *, method: str = "GET",
**kwargs: Any) -> bytes:
seen.append((host, slug, url))
return (FIXTURES / "workday-detail.json").read_bytes()
monkeypatch.setattr(ats, "_get", fake_get)
row = workday.rows(_load("workday.json"), SLUG)[0]
got = workday.detail(ats._getter(object(), "workday", SLUG), SLUG, row) # type: ignore[arg-type]
assert got["remote"] == "remote"
assert seen[0][:2] == ("workday", SLUG)
# ------------------------------------------- slugs, hosts and robots.txt
GOOD = ["lego.wd103/LEGO_External", "redhat.wd5/jobs", "unitytech.wd1/Unity",
"gn.wd3/GN-Careers", "misterspex.wd103/Mister_Spex_Careers", "a-b.wd1/x"]
@pytest.mark.parametrize("slug", GOOD)
def test_a_slug_is_tenant_data_centre_and_site(slug: str) -> None:
assert workday.slug_ok(slug) and ats.is_known_target(f"workday:{slug}")
@pytest.mark.parametrize("slug", [
"", "lego", "lego.wd103", "lego.wd103/", "lego.wd103/LEGO_External/", "/LEGO_External",
"lego.wd/LEGO_External", "lego.wdx/x", "lego.WD103/x", "LEGO.wd103/x", "le_go.wd103/x",
"lego.wd103/LEGO External", " lego.wd103/x", "lego.wd103/x ", "lego.wd103/x\n",
"lego.wd103/x\r\n", "lego.wd103\n/x", "lego.wd103/x/y", "lego.wd103/x?y=1",
"lego.wd103/x#y", "lego.wd103/..", "lego.wd103/.", "lego.wd103/x%2fy", "lego.wd103/%2f",
"lego.wd103/x@evil.example", "lego@evil.example.wd103/x", "lego.wd103:443/x",
"lego.wd103/x:80", "localhost/x", "lego.wd103.example.com/x", "127.0.0.1/x",
"127.wd1/../x", "lego.evil.wd103/x", "lego..wd103/x", "lego.wd103/x;y", "lego.wd103/x\\y",
])
def test_a_hostile_or_malformed_slug_is_refused(slug: str) -> None:
assert not workday.slug_ok(slug)
assert not ats.is_known_target(f"workday:{slug}")
assert not workday.allowed(slug)(f"{slug.split('/')[0].split('@')[-1]}.myworkdayjobs.com")
def test_a_fetch_may_reach_the_tenants_own_host_only() -> None:
allow = workday.allowed("lego.wd103/LEGO_External")
assert allow("lego.wd103.myworkdayjobs.com") and allow("LEGO.WD103.MYWORKDAYJOBS.COM")
for other in ("lego.wd3.myworkdayjobs.com", "novonesis.wd103.myworkdayjobs.com",
"wd103.myworkdayjobs.com", "myworkdayjobs.com", "lego.wd103.evil.example",
"lego.wd103.myworkdayjobs.com.evil.example", "evil.lego.wd103.myworkdayjobs.com",
"www.lego.wd103.myworkdayjobs.com", "localhost", "127.0.0.1", ""):
assert not allow(other), other
assert ats._allowed_host("workday", "lego.wd103/LEGO_External")("lego.wd103.myworkdayjobs.com")
assert not ats._allowed_host("workday", "lego.wd103/LEGO_External")(
"redhat.wd5.myworkdayjobs.com")
def test_a_redirect_off_the_tenant_is_refused() -> None:
def handler(request: httpx.Request) -> httpx.Response:
return httpx.Response(302, headers={"location": "https://evil.example/wday"})
with httpx.Client(transport=httpx.MockTransport(handler)) as client, \
pytest.raises(ats._Refused):
ats._get(client, "https://lego.wd103.myworkdayjobs.com/wday/cxs/lego/LEGO_External/jobs",
"workday", "lego.wd103/LEGO_External", method="POST", payload={})
def test_the_case_of_the_site_is_kept() -> None:
assert workday.KEEP_CASE is True
assert workday.careers_url("lego.wd103/LEGO_External") == \
"https://lego.wd103.myworkdayjobs.com/LEGO_External"
assert ats.careers_url("workday:redhat.wd5/jobs") == \
"https://redhat.wd5.myworkdayjobs.com/jobs"
assert "workday" in ats.HOSTS and ats.HOSTS["workday"] == "Workday"
def test_robots_page_is_the_site_with_its_closing_slash() -> None:
page = workday.robots_page("novonesis.wd103/Novonesis_Careers")
assert page == "https://novonesis.wd103.myworkdayjobs.com/Novonesis_Careers/"
assert httpx.URL(page).host == "novonesis.wd103.myworkdayjobs.com"
assert workday.allowed("novonesis.wd103/Novonesis_Careers")(httpx.URL(page).host)
@pytest.mark.parametrize(("slug", "robots", "allowed"), [
# As the tenants write them: a site that is disallowed, and one that is not.
("novonesis.wd103/Novonesis_Careers",
"User-agent: *\nDisallow: /Novonesis_Careers/\nDisallow: /Novonesis_Careers_Private/\n"
"Disallow: /refreshFacet/\n", False),
("darktrace.wd3/DarktaceExternal", "User-agent: *\nDisallow: /DarktaceExternal/\n", False),
("lego.wd103/LEGO_External",
"Sitemap: https://lego.wd103.myworkdayjobs.com/LEGO_External/siteMap.xml\n"
"User-agent: *\nAllow: /LEGO_External/\nDisallow: /LEGO_Executive/\n"
"Disallow: /refreshFacet/\n", True),
# Paths are case-sensitive: Red Hat's `Jobs` rule and its site `jobs`.
("redhat.wd5/jobs", "User-agent: *\nAllow: /Jobs/\nDisallow: /refreshFacet/\n", True),
("zendesk.wd1/zendesk", "User-agent: *\nAllow: /zendesk/\nDisallow: /refreshFacet/\n", True),
])
def test_robots_txt_is_read_against_the_site_page(slug: str, robots: str, allowed: bool) -> None:
assert ats._robots_allows(robots.encode(), workday.robots_page(slug)) is allowed
def test_the_site_page_without_its_slash_would_have_slipped_past_the_rule() -> None:
"""Why `robots_page` ends in a slash."""
rule = b"User-agent: *\nDisallow: /Novonesis_Careers/\n"
assert ats._robots_allows(rule, "https://novonesis.wd103.myworkdayjobs.com/Novonesis_Careers")
assert not ats._robots_allows(
rule, "https://novonesis.wd103.myworkdayjobs.com/Novonesis_Careers/")
# -------------------------------------------------------------- discovery
def _found(text: str) -> list[tuple[str, str]]:
return [(host, slug) for host, slug, _url in discover.boards_in(text)]
#: The twelve career sites of `docs/plan-hosts/workday.md`, as a person opens
#: them, and the slug discovery names for each.
TWELVE = [
("https://zendesk.wd1.myworkdayjobs.com/zendesk", "zendesk.wd1/zendesk"),
("https://unitytech.wd1.myworkdayjobs.com/Unity", "unitytech.wd1/Unity"),
("https://lego.wd103.myworkdayjobs.com/LEGO_External", "lego.wd103/LEGO_External"),
("https://saxobank.wd3.myworkdayjobs.com/CareeratSaxoBank",
"saxobank.wd3/CareeratSaxoBank"),
("https://novonesis.wd103.myworkdayjobs.com/Novonesis_Careers",
"novonesis.wd103/Novonesis_Careers"),
("https://gn.wd3.myworkdayjobs.com/GN-Careers", "gn.wd3/GN-Careers"),
("https://equinor.wd3.myworkdayjobs.com/EQNR", "equinor.wd3/EQNR"),
("https://axis.wd3.myworkdayjobs.com/External_Career_Site",
"axis.wd3/External_Career_Site"),
("https://misterspex.wd103.myworkdayjobs.com/de-DE/Mister_Spex_Careers",
"misterspex.wd103/Mister_Spex_Careers"),
("https://darktrace.wd3.myworkdayjobs.com/DarktaceExternal",
"darktrace.wd3/DarktaceExternal"),
("https://criteo.wd3.myworkdayjobs.com/Criteo_Career_Site",
"criteo.wd3/Criteo_Career_Site"),
("https://redhat.wd5.myworkdayjobs.com/jobs", "redhat.wd5/jobs"),
]
@pytest.mark.parametrize(("url", "slug"), TWELVE)
def test_discovery_finds_the_slug_of_each_career_site(url: str, slug: str) -> None:
assert _found(url) == [("workday", slug)]
assert workday.slug_ok(slug)
@pytest.mark.parametrize("url", [
"https://lego.wd103.myworkdayjobs.com/en-US/LEGO_External",
"https://lego.wd103.myworkdayjobs.com/de-DE/LEGO_External/",
"https://lego.wd103.myworkdayjobs.com/en-GB/LEGO_External/job/Billund/Analyst_R1",
"https://lego.wd103.myworkdayjobs.com/LEGO_External/job/Billund/Analyst_R1?source=x",
"https://lego.wd103.myworkdayjobs.com/wday/cxs/lego/LEGO_External/jobs",
'<a href="https://lego.wd103.myworkdayjobs.com/en-US/LEGO_External">Jobs</a>',
"lego.wd103.myworkdayjobs.com/LEGO_External",
])
def test_discovery_finds_a_site_with_or_without_a_locale_or_a_role_path(url: str) -> None:
assert _found(url) == [("workday", "lego.wd103/LEGO_External")]
def test_discovery_finds_a_site_named_jobs_with_and_without_a_locale() -> None:
for url in ("https://redhat.wd5.myworkdayjobs.com/jobs",
"https://redhat.wd5.myworkdayjobs.com/en-US/jobs",
"https://redhat.wd5.myworkdayjobs.com/en-US/jobs/job/Raleigh/x_R-1"):
assert _found(url) == [("workday", "redhat.wd5/jobs")], url
@pytest.mark.parametrize("url", [
"https://lego.wd103.myworkdayjobs.com", "https://lego.wd103.myworkdayjobs.com/",
"https://lego.wd103.myworkdayjobs.com/en-US", "https://lego.wd103.myworkdayjobs.com/en-US/",
"https://wd5.myworkdayjobs.com/recruiting/acme/site",
"https://lego.myworkdayjobs.com/LEGO_External",
"https://LEGO.wd103.myworkdayjobs.com/LEGO_External",
"https://x.lego.wd103.myworkdayjobs.com.evil.example/LEGO_External",
])
def test_discovery_names_no_board_where_there_is_no_site_or_no_tenant(url: str) -> None:
assert _found(url) == []
def test_discovery_keeps_the_case_of_the_site_and_names_each_board_once() -> None:
text = ("https://lego.wd103.myworkdayjobs.com/LEGO_External "
"https://lego.wd103.myworkdayjobs.com/en-US/LEGO_External/job/x "
"https://lego.wd103.myworkdayjobs.com/LEGO_Executive")
assert _found(text) == [("workday", "lego.wd103/LEGO_External"),
("workday", "lego.wd103/LEGO_Executive")]
assert "workday" in discover.READABLE