diff --git a/app/prep/hosts/ashby.py b/app/prep/hosts/ashby.py new file mode 100644 index 0000000..0d0db59 --- /dev/null +++ b/app/prep/hosts/ashby.py @@ -0,0 +1,8 @@ +"""Ashby's words, mapped to the app's.""" + +#: `workplaceType`. +REMOTE: dict[str, str] = {"remote": "remote", "hybrid": "hybrid", "onsite": "onsite"} + +#: `employmentType`. +EMPLOYMENT: dict[str, str] = {"fulltime": "full_time", "parttime": "part_time", "intern": "internship", + "contract": "contract", "temporary": "temporary"} diff --git a/app/prep/hosts/bamboohr.py b/app/prep/hosts/bamboohr.py new file mode 100644 index 0000000..5e1d774 --- /dev/null +++ b/app/prep/hosts/bamboohr.py @@ -0,0 +1,12 @@ +"""BambooHR's words, mapped to the app's.""" + +#: `employmentStatusLabel`. BambooHR's labels are the company's own ("Full-Time", +#: "Part-Time", "Contract", "Intern"). +EMPLOYMENT: dict[str, str] = { + "full-time": "full_time", "full time": "full_time", "part-time": "part_time", + "part time": "part_time", "contract": "contract", "contractor": "contract", + "temporary": "temporary", "intern": "internship", "internship": "internship", + "freelance": "freelance"} + +#: `locationType`. Anything else says nothing. +REMOTE: dict[str, str] = {"0": "onsite", "1": "remote", "2": "hybrid"} diff --git a/app/prep/hosts/deel.py b/app/prep/hosts/deel.py new file mode 100644 index 0000000..8d289c5 --- /dev/null +++ b/app/prep/hosts/deel.py @@ -0,0 +1,11 @@ +"""Deel's words, mapped to the app's.""" + +#: `workArrangementEnum`. +REMOTE: dict[str, str] = {"on_site": "onsite", "hybrid": "hybrid", "remote": "remote"} + +#: The name of a `jobEmploymentTypes` entry. +EMPLOYMENT: dict[str, str] = { + "full-time": "full_time", "full time": "full_time", "part-time": "part_time", + "part time": "part_time", "contract": "contract", "contractor": "contract", + "consultant": "contract", "temporary": "temporary", "intern": "internship", + "internship": "internship", "freelance": "freelance"} diff --git a/app/prep/hosts/eightfold.py b/app/prep/hosts/eightfold.py new file mode 100644 index 0000000..022d816 --- /dev/null +++ b/app/prep/hosts/eightfold.py @@ -0,0 +1,5 @@ +"""Eightfold's words, mapped to the app's.""" + +#: `workLocationOption`. Only "onsite" and "hybrid" were seen; the other +#: spellings are the obvious ones. +REMOTE: dict[str, str] = {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid", "remote": "remote"} diff --git a/app/prep/hosts/gem.py b/app/prep/hosts/gem.py new file mode 100644 index 0000000..77f8100 --- /dev/null +++ b/app/prep/hosts/gem.py @@ -0,0 +1,10 @@ +"""Gem's words, mapped to the app's.""" + +#: `job.locationType`. +REMOTE: dict[str, str] = {"in_office": "onsite", "hybrid": "hybrid", "remote": "remote"} + +#: `job.employmentType`. +EMPLOYMENT: dict[str, str] = { + "full_time": "full_time", "part_time": "part_time", "contract": "contract", + "contractor": "contract", "intern": "internship", "internship": "internship", + "temporary": "temporary", "freelance": "freelance"} diff --git a/app/prep/hosts/hibob.py b/app/prep/hosts/hibob.py new file mode 100644 index 0000000..7f24d35 --- /dev/null +++ b/app/prep/hosts/hibob.py @@ -0,0 +1,13 @@ +"""HiBob's words, mapped to the app's.""" + +#: `employmentType`, the company's own name for it. "Permanent" says nothing +#: about hours and stays unmapped. +EMPLOYMENT: dict[str, str] = { + "regular full time": "full_time", "full time": "full_time", + "full-time": "full_time", "regular part time": "part_time", + "part time": "part_time", "part-time": "part_time", "contract": "contract", + "contractor": "contract", "temporary": "temporary", "fixed term": "temporary", + "intern": "internship", "internship": "internship", "freelance": "freelance"} + +#: `workspaceTypeId`. +REMOTE: dict[str, str] = {"remote": "remote", "hybrid": "hybrid", "on_site": "onsite", "onsite": "onsite"} diff --git a/app/prep/hosts/jibe.py b/app/prep/hosts/jibe.py new file mode 100644 index 0000000..4f24331 --- /dev/null +++ b/app/prep/hosts/jibe.py @@ -0,0 +1,7 @@ +"""Jibe's words, mapped to the app's.""" + +#: `employment_type`. +EMPLOYMENT: dict[str, str] = { + "full_time": "full_time", "part_time": "part_time", "contractor": "contract", + "contract": "contract", "temporary": "temporary", "intern": "internship", + "internship": "internship", "freelance": "freelance"} diff --git a/app/prep/hosts/jobylon.py b/app/prep/hosts/jobylon.py new file mode 100644 index 0000000..d10518d --- /dev/null +++ b/app/prep/hosts/jobylon.py @@ -0,0 +1,21 @@ +"""Jobylon's words, mapped to the app's.""" + +#: The embed's `experience`. Only the coarse levels are mapped; "Experienced" +#: sits between "Mid level" and the managerial levels and says too little to +#: place, so it stays unmapped. +SENIORITY: dict[str, str] = { + "student": "intern", "internship": "intern", "trainee": "intern", + "entry level": "junior", "entry-level": "junior", "junior": "junior", + "graduate": "junior", "mid level": "mid", "mid-level": "mid", "mid": "mid", + "senior": "senior", "lead": "lead", "manager": "manager", "director": "director", + "executive": "exec", "not applicable": ""} + +#: The embed's `employment_type`. +EMPLOYMENT: dict[str, str] = { + "full-time": "full_time", "full time": "full_time", "part-time": "part_time", + "part time": "part_time", "contract": "contract", "consultant": "contract", + "temporary": "temporary", "internship": "internship", "intern": "internship", + "freelance": "freelance", "summer job": "temporary", "seasonal": "temporary"} + +#: `workspace`. +REMOTE: dict[str, str] = {"remote": "remote", "hybrid": "hybrid", "on-site": "onsite", "onsite": "onsite"} diff --git a/app/prep/hosts/lever.py b/app/prep/hosts/lever.py new file mode 100644 index 0000000..1195002 --- /dev/null +++ b/app/prep/hosts/lever.py @@ -0,0 +1,9 @@ +"""Lever's words, mapped to the app's.""" + +#: `categories.commitment`. A commitment is free text on Lever ("Permanent" is +#: seen too and says nothing about hours). +EMPLOYMENT: dict[str, str] = { + "full-time": "full_time", "full time": "full_time", "fulltime": "full_time", + "part-time": "part_time", "part time": "part_time", "parttime": "part_time", + "intern": "internship", "internship": "internship", "contract": "contract", + "contractor": "contract", "temporary": "temporary", "freelance": "freelance"} diff --git a/plugins/readers/ashby.py b/plugins/readers/ashby.py index dd70ae6..c60efce 100644 --- a/plugins/readers/ashby.py +++ b/plugins/readers/ashby.py @@ -15,7 +15,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Place, Reads, Row -from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, table_word, yearly_amount +from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, yearly_amount log = logging.getLogger(__name__) @@ -36,13 +36,6 @@ READS = Reads( _API = "api.ashbyhq.com" -#: `workplaceType` -> `store._remote`'s words. `isRemote` is true for hybrid -#: roles too, so it is only the fallback when the role has no `workplaceType`. -_WORKPLACE = {"remote": "remote", "hybrid": "hybrid", "onsite": "onsite"} - -#: `employmentType` -> the app's employment words. -_EMPLOYMENT = {"fulltime": "full_time", "parttime": "part_time", "intern": "internship", - "contract": "contract", "temporary": "temporary"} def slug_ok(slug: str) -> bool: @@ -113,12 +106,12 @@ def _salary_text(compensation: dict[str, Any]) -> str: or compensation.get("scrapeableCompensationSalarySummary") or "") -def _places(j: dict[str, Any], workplace: str | None) -> list[Place]: +def _places(j: dict[str, Any], workplace: str) -> list[Place]: """The primary `location`, then each of `secondaryLocations`, in the host's words. The primary is remote or an office as `workplaceType` says; a place that names itself remote is remote.""" primary = (j.get("location") or "").strip() - named = [(primary, {"remote": True, "hybrid": False, "onsite": False}.get(workplace or ""))] + named = [(primary, {"remote": True, "hybrid": False, "onsite": False}.get(workplace.lower()))] named += [(str((s or {}).get("location") or "").strip(), None) for s in j.get("secondaryLocations") or []] out: list[Place] = [] @@ -127,10 +120,6 @@ def _places(j: dict[str, Any], workplace: str | None) -> list[Place]: return out -def _employment(value: Any) -> str | None: - return table_word(_EMPLOYMENT, value, log, "employmentType") - - def parse(body: bytes, slug: str) -> list[Row]: data = json.loads(body) rows = [] @@ -142,7 +131,7 @@ def parse(body: bytes, slug: str) -> list[Row]: description = j.get("descriptionHtml") or j.get("descriptionPlain") or "" compensation = j.get("compensation") or {} salary_min, salary_max, currency = _salary(compensation.get("summaryComponents") or []) - workplace = _WORKPLACE.get(str(j.get("workplaceType") or "").strip().lower()) + workplace = str(j.get("workplaceType") or "").strip() places = _places(j, workplace) row: Row = { "source_id": str(j.get("id") or ""), @@ -153,13 +142,13 @@ def parse(body: bytes, slug: str) -> list[Row]: "posted": parse_dt(j.get("publishedAt")), "department": (j.get("department") or j.get("team") or "").strip(), "description": strip_html(description), - "remote": workplace or j.get("isRemote"), + "remote": workplace or j.get("isRemote"), # `isRemote` is true for hybrid too "salary_text": _salary_text(compensation), "salary_min": salary_min, "salary_max": salary_max, "currency": currency, } - if employment := _employment(j.get("employmentType")): + if employment := str(j.get("employmentType") or "").strip(): row["employment"] = employment rows.append(row) return rows diff --git a/plugins/readers/bamboohr.py b/plugins/readers/bamboohr.py index 95de9e9..dc9d031 100644 --- a/plugins/readers/bamboohr.py +++ b/plugins/readers/bamboohr.py @@ -23,7 +23,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Place, Reads, Row -from ._shared import Get, label_slug_ok, only, parse_dt, place, table_word +from ._shared import Get, label_slug_ok, only, parse_dt, place log = logging.getLogger(__name__) @@ -34,13 +34,6 @@ READS = Reads( robots="read: robots.txt allows /careers (checked 2026-09-29)", ) -#: `employmentStatusLabel` -> the app's employment words. BambooHR's labels are -#: the company's own ("Full-Time", "Part-Time", "Contract", "Intern"). -_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "part-time": "part_time", - "part time": "part_time", "contract": "contract", "contractor": "contract", - "temporary": "temporary", "intern": "internship", "internship": "internship", - "freelance": "freelance"} - NAME = "bamboohr" LABEL = "BambooHR" PATTERNS = ( @@ -49,9 +42,6 @@ PATTERNS = ( r"https?://(?!(?:app|resources|documentation|help)\.)([a-z0-9-]+)\.bamboohr\.com", ) -#: `locationType` -> `store._remote`'s words. Anything else says nothing. -_REMOTE = {"0": "onsite", "1": "remote", "2": "hybrid"} - #: Sent on the detail read: without it the same URL answers the page's HTML. _JSON = {"Accept": "application/json"} @@ -76,10 +66,11 @@ def feed_url(slug: str, ask: Ask) -> str: return f"https://{host(slug)}/careers/list" -def _remote(j: dict[str, Any]) -> str | None: +def _remote(j: dict[str, Any]) -> bool | str | None: + """`isRemote` when true, else `locationType` as the host writes it ("0", "1", "2").""" if j.get("isRemote") is True: - return "remote" - return _REMOTE.get(str(j.get("locationType") if j.get("locationType") is not None else "")) + return True + return None if j.get("locationType") is None else str(j["locationType"]).strip() or None def _place(j: dict[str, Any]) -> str: @@ -99,10 +90,6 @@ def _places(j: dict[str, Any]) -> list[Place]: return [place(text)] if text else [] -def _employment(j: dict[str, Any]) -> str | None: - return table_word(_EMPLOYMENT, j.get("employmentStatusLabel"), log, "employmentStatusLabel") - - def parse(body: bytes, slug: str) -> list[Row]: """`/careers/list` -> `{"meta": {"totalCount": n}, "result": [...]}`. A role has `id`, `jobOpeningName`, `departmentLabel`, `location` (`city`, @@ -136,7 +123,7 @@ def parse(body: bytes, slug: str) -> list[Row]: "remote": _remote(j), "salary_text": "", # the list states no pay; the detail's `compensation` was null } - if employment := _employment(j): + if employment := str(j.get("employmentStatusLabel") or "").strip(): row["employment"] = employment out.append(row) return out @@ -160,6 +147,6 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]: if place := _place(opening): out["location"] = place out["places"] = _places(opening) - if remote := _remote(opening): + if (remote := _remote(opening)) is not None: out["remote"] = remote return out diff --git a/plugins/readers/deel.py b/plugins/readers/deel.py index 54b51b6..a761ff0 100644 --- a/plugins/readers/deel.py +++ b/plugins/readers/deel.py @@ -24,7 +24,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Reads, Row -from ._shared import num, only, parse_dt, pay_line, table_word +from ._shared import num, only, parse_dt, pay_line log = logging.getLogger(__name__) @@ -59,15 +59,6 @@ _PUSH = re.compile(r'self\.__next_f\.push\(\[1,("(?:[^"\\]|\\.)*")\]\)') _ROW = re.compile(rb"([0-9a-f]*):") _TEXT = re.compile(rb"T([0-9a-f]+),") -#: Deel's `workArrangementEnum` -> `store._remote`'s words. -_REMOTE = {"ON_SITE": "onsite", "HYBRID": "hybrid", "REMOTE": "remote"} - -#: The name of a `jobEmploymentTypes` entry -> the app's employment words. -_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "part-time": "part_time", - "part time": "part_time", "contract": "contract", "contractor": "contract", - "consultant": "contract", "temporary": "temporary", "intern": "internship", - "internship": "internship", "freelance": "freelance"} - def slug_ok(slug: str) -> bool: return bool(_SLUG.fullmatch(slug)) @@ -121,10 +112,10 @@ def _postings(body: bytes) -> tuple[list[dict[str, Any]], dict[str, str]]: def _employment(job: dict[str, Any]) -> str | None: - """The first `jobEmploymentTypes` entry that names a known type.""" + """The name of the first `jobEmploymentTypes` entry that has one.""" for entry in job.get("jobEmploymentTypes") or []: name = ((entry or {}).get("employmentType") or {}).get("name") - if found := table_word(_EMPLOYMENT, name, log, "employment type"): + if found := str(name or "").strip(): return found return None @@ -155,7 +146,7 @@ def parse(body: bytes, slug: str) -> list[Row]: description = p.get("richtextDescription") or "" if description.startswith("$"): description = stream.get(description[1:], "") - arrangement = str(job.get("workArrangementEnum") or "") + arrangement = str(job.get("workArrangementEnum") or "").strip() remote = {"REMOTE": True, "HYBRID": False, "ON_SITE": False}.get(arrangement) row: Row = { "source_id": post_id, @@ -166,7 +157,7 @@ def parse(body: bytes, slug: str) -> list[Row]: "posted": parse_dt(published.get("createdAt") or p.get("createdAt")), "department": ", ".join(dict.fromkeys(departments)), "description": html.unescape(strip_html(description)), - "remote": _REMOTE.get(str(job.get("workArrangementEnum") or "")), + "remote": arrangement or None, "salary_text": (pay_line(num(pay.get("minAmount")), num(pay.get("maxAmount")), pay.get("currencyIsoCode"), "") if p.get("isCompensationVisible") else ""), diff --git a/plugins/readers/eightfold.py b/plugins/readers/eightfold.py index e015f82..0d990e6 100644 --- a/plugins/readers/eightfold.py +++ b/plugins/readers/eightfold.py @@ -70,10 +70,6 @@ _NAME = re.compile(r"[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9] #: Names a private network uses, never a company's career site. _LOCAL = (".localhost", ".local", ".internal", ".lan", ".home.arpa") -#: `workLocationOption` -> `store._remote`'s words. Only "onsite" and "hybrid" -#: were seen; the other spellings are the obvious ones. -_REMOTE = {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid", "remote": "remote"} - def parts(slug: str) -> tuple[str, str]: """`(host, domain)` of a slug, lowercased.""" @@ -162,7 +158,7 @@ def rows(positions: list[dict[str, Any]], slug: str) -> list[Row]: "posted": parse_dt(p.get("creationTs") or p.get("postedTs")), "department": str(p.get("department") or "").strip(), "description": "", - "remote": _REMOTE.get(str(p.get("workLocationOption") or "").strip().lower()), + "remote": str(p.get("workLocationOption") or "").strip() or None, "salary_text": "", }) return out diff --git a/plugins/readers/gem.py b/plugins/readers/gem.py index bb8c6d7..ee90a1e 100644 --- a/plugins/readers/gem.py +++ b/plugins/readers/gem.py @@ -27,7 +27,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Place, Reads, Row -from ._shared import Get, Page, add_place, only, parse_dt, table_word +from ._shared import Get, Page, add_place, only, parse_dt log = logging.getLogger(__name__) @@ -65,14 +65,6 @@ DETAIL_QUERY = ( "job { id locationType employmentType requisitionId teamDisplayName " "department { id extId name } } compensationHtml } }") -#: `job.locationType` -> `store._remote`'s words. -_REMOTE = {"IN_OFFICE": "onsite", "HYBRID": "hybrid", "REMOTE": "remote"} - -#: `job.employmentType` -> the app's employment words. -_EMPLOYMENT = {"full_time": "full_time", "part_time": "part_time", "contract": "contract", - "contractor": "contract", "intern": "internship", "internship": "internship", - "temporary": "temporary", "freelance": "freelance"} - def slug_ok(slug: str) -> bool: return bool(_BOARD.fullmatch(slug)) @@ -134,9 +126,9 @@ def rows(postings: list[dict[str, Any]], slug: str) -> list[Row]: add_place(places, {"text": text, "remote": loc["isRemote"] if isinstance(loc.get("isRemote"), bool) else None}) job = p.get("job") or {} - remote = _REMOTE.get(str(job.get("locationType") or "").upper()) + remote: bool | str | None = str(job.get("locationType") or "").strip() or None if remote is None and locations and all(loc.get("isRemote") for loc in locations): - remote = "remote" + remote = True row: Row = { "source_id": ext_id, "title": title, @@ -149,7 +141,7 @@ def rows(postings: list[dict[str, Any]], slug: str) -> list[Row]: "remote": remote, "salary_text": "", } - if employment := table_word(_EMPLOYMENT, job.get("employmentType"), log, "employmentType"): + if employment := str(job.get("employmentType") or "").strip(): row["employment"] = employment out.append(row) return out diff --git a/plugins/readers/hibob.py b/plugins/readers/hibob.py index 31fa9df..a1a9204 100644 --- a/plugins/readers/hibob.py +++ b/plugins/readers/hibob.py @@ -23,7 +23,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Reads, Row -from ._shared import Get, Page, label_slug_ok, num, only, parse_dt, pay_line, table_word, yearly_amount +from ._shared import Get, Page, label_slug_ok, num, only, parse_dt, pay_line, yearly_amount log = logging.getLogger(__name__) @@ -38,21 +38,10 @@ READS = Reads( "app's index page with no rules (checked 2026-09-29)", ) -#: `employmentType`, the company's own name for it -> the app's employment -#: words. "Permanent" says nothing about hours and stays unmapped. -_EMPLOYMENT = {"regular full time": "full_time", "full time": "full_time", - "full-time": "full_time", "regular part time": "part_time", - "part time": "part_time", "part-time": "part_time", "contract": "contract", - "contractor": "contract", "temporary": "temporary", "fixed term": "temporary", - "intern": "internship", "internship": "internship", "freelance": "freelance"} - NAME = "hibob" LABEL = "HiBob" PATTERNS = (r"https?://([a-z0-9-]+)\.careers\.hibob\.com",) -#: HiBob's `workspaceTypeId` -> `store._remote`'s words. -_REMOTE = {"remote": "remote", "hybrid": "hybrid", "on_site": "onsite", "onsite": "onsite"} - #: The texts of an ad, in the order the ad shows them. _SECTIONS = ("description", "responsibilities", "requirements", "benefits") @@ -126,13 +115,13 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]: "posted": parse_dt(ad.get("publishedAt")), "department": str(ad.get("department") or "").strip(), "description": " ".join(html.unescape(text).split()), - "remote": _REMOTE.get(str(ad.get("workspaceTypeId") or "").strip().lower()), + "remote": str(ad.get("workspaceTypeId") or "").strip() or None, "salary_text": pay_line(lo, hi, currency, period), "salary_min": salary_min, "salary_max": salary_max, "currency": code, } - if employment := table_word(_EMPLOYMENT, ad.get("employmentType"), log, "employmentType"): + if employment := str(ad.get("employmentType") or "").strip(): row["employment"] = employment out.append(row) return out diff --git a/plugins/readers/jibe.py b/plugins/readers/jibe.py index 0e12946..7e2e617 100644 --- a/plugins/readers/jibe.py +++ b/plugins/readers/jibe.py @@ -38,7 +38,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Place, Reads, Row -from ._shared import Get, Page, add_place, only, parse_dt, place, table_word +from ._shared import Get, Page, add_place, only, parse_dt, place log = logging.getLogger(__name__) @@ -49,11 +49,6 @@ READS = Reads( robots="read: robots.txt allows /jobs, with crawl-delay 5 not honoured (checked 2026-09-29)", ) -#: `employment_type` -> the app's employment words. -_EMPLOYMENT = {"full_time": "full_time", "part_time": "part_time", "contractor": "contract", - "contract": "contract", "temporary": "temporary", "intern": "internship", - "internship": "internship", "freelance": "freelance"} - NAME = "jibe" LABEL = "Jibe" PATTERNS = ( @@ -157,10 +152,10 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]: } # One code, for a role at one place: over several countries it would # gate the others by the site's own. - code = str(j.get("country_code") or "").strip().upper() - if len(places) == 1 and re.fullmatch(r"[A-Z]{2}", code): + code = str(j.get("country_code") or "").strip() + if len(places) == 1 and code: row["country"] = code - if employment := table_word(_EMPLOYMENT, j.get("employment_type"), log, "employment_type"): + if employment := str(j.get("employment_type") or "").strip(): row["employment"] = employment out.append(row) return out diff --git a/plugins/readers/jobylon.py b/plugins/readers/jobylon.py index 74fc7b3..dc519b7 100644 --- a/plugins/readers/jobylon.py +++ b/plugins/readers/jobylon.py @@ -26,7 +26,7 @@ from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Reads, Row -from ._shared import Get, parse_dt, place, table_word +from ._shared import Get, parse_dt, place log = logging.getLogger(__name__) @@ -58,28 +58,10 @@ _SLUG = re.compile(r"[0-9]{1,12}") #: from. _ROLE_PATH = re.compile(r"/jobs/[0-9]+(?:-[A-Za-z0-9_-]*)?/?") -#: The embed's `experience` -> `app.models.SENIORITIES`. Only the coarse levels -#: are mapped; "Experienced" sits between "Mid level" and the managerial -#: levels and says too little to place, so it stays unmapped and is logged. -_SENIORITY = {"student": "intern", "internship": "intern", "trainee": "intern", - "entry level": "junior", "entry-level": "junior", "junior": "junior", - "graduate": "junior", "mid level": "mid", "mid-level": "mid", "mid": "mid", - "senior": "senior", "lead": "lead", "manager": "manager", "director": "director", - "executive": "exec", "not applicable": ""} - -#: The embed's `employment_type` -> the app's employment words. -_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "part-time": "part_time", - "part time": "part_time", "contract": "contract", "consultant": "contract", - "temporary": "temporary", "internship": "internship", "intern": "internship", - "freelance": "freelance", "summer job": "temporary", "seasonal": "temporary"} - _ASSIGNMENT = "JBL.embed_v2['jobs'] = " _KEY = re.compile(r"[A-Za-z_][A-Za-z0-9_]*") _TRAILING_COMMA = re.compile(r",(\s*[\]}])") -#: Jobylon's `workspace` -> `store._remote`'s words. -_REMOTE = {"remote": "remote", "hybrid": "hybrid", "on-site": "onsite", "onsite": "onsite"} - #: The English month names, by their first three letters, in the spellings #: `published_date` uses ("Sept. 25, 2026"). _MONTHS = {m: i for i, m in enumerate( @@ -205,7 +187,7 @@ def parse(body: bytes, slug: str) -> list[Row]: "posted": _published(j.get("published_date")), "department": "" if function == "All functions" else function, "description": "", - "remote": _REMOTE.get(str(j.get("workspace") or "").strip().lower()), + "remote": str(j.get("workspace") or "").strip() or None, "salary_text": "", # the embed states no pay } # `summary` is the text the company gave the listing, the string @@ -213,9 +195,9 @@ def parse(body: bytes, slug: str) -> list[Row]: summary = " ".join(html.unescape(strip_html(str(j.get("summary") or ""))).split()) if summary and summary != "None": row["teaser"] = summary - if seniority := table_word(_SENIORITY, j.get("experience"), log, "experience"): + if seniority := str(j.get("experience") or "").strip(): row["seniority"] = seniority - if employment := table_word(_EMPLOYMENT, j.get("employment_type"), log, "employment_type"): + if employment := str(j.get("employment_type") or "").strip(): row["employment"] = employment out.append(row) return out diff --git a/plugins/readers/lever.py b/plugins/readers/lever.py index f953792..83bb2f5 100644 --- a/plugins/readers/lever.py +++ b/plugins/readers/lever.py @@ -17,14 +17,13 @@ from __future__ import annotations import json import logging -import re from collections.abc import Callable from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Place, Reads, Row -from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, table_word, yearly_amount +from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, yearly_amount log = logging.getLogger(__name__) @@ -36,13 +35,6 @@ READS = Reads( robots="api: no robots.txt check needed (public board API), 2026-09-30", ) -#: `categories.commitment` -> the app's employment words. A commitment is free -#: text on Lever ("Permanent" is seen too and says nothing about hours). -_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "fulltime": "full_time", - "part-time": "part_time", "part time": "part_time", "parttime": "part_time", - "intern": "internship", "internship": "internship", "contract": "contract", - "contractor": "contract", "temporary": "temporary", "freelance": "freelance"} - NAME = "lever" LABEL = "Lever" RANK = 20 @@ -153,10 +145,10 @@ def parse(body: bytes, slug: str) -> list[Row]: } # `country` is one code, for a role at one place; over several it would # gate the others by the first's country. - country = str(j.get("country") or "").strip().upper() - if len(places) == 1 and re.fullmatch(r"[A-Z]{2}", country): + country = str(j.get("country") or "").strip() + if len(places) == 1 and country: row["country"] = country - if employment := table_word(_EMPLOYMENT, categories.get("commitment"), log, "commitment"): + if employment := str(categories.get("commitment") or "").strip(): row["employment"] = employment rows.append(row) return rows diff --git a/tests/test_ats_ashby.py b/tests/test_ats_ashby.py index 49cd788..b776798 100644 --- a/tests/test_ats_ashby.py +++ b/tests/test_ats_ashby.py @@ -25,14 +25,14 @@ def test_the_primary_and_every_secondary_location_are_places() -> None: assert second["places"] == [{"text": "Dublin", "remote": True}] -def test_a_hybrid_role_is_not_remote_although_the_host_flags_it() -> None: +def test_remote_is_the_workplace_type_as_the_host_writes_it() -> None: first, second = ashby.parse(BOARD, "acme") - assert first["remote"] == "hybrid" and second["remote"] == "remote" + assert first["remote"] == "Hybrid" and second["remote"] == "Remote" -def test_the_employment_type_is_mapped() -> None: +def test_the_employment_type_is_the_hosts_word() -> None: first, second = ashby.parse(BOARD, "acme") - assert (first["employment"], second["employment"]) == ("full_time", "contract") + assert (first["employment"], second["employment"]) == ("FullTime", "Contract") def test_it_declares_a_whole_listing_of_trusted_dates_and_no_robots_check() -> None: diff --git a/tests/test_ats_bamboohr.py b/tests/test_ats_bamboohr.py index f97357e..c7cd28a 100644 --- a/tests/test_ats_bamboohr.py +++ b/tests/test_ats_bamboohr.py @@ -47,15 +47,15 @@ def test_a_listing_becomes_rows() -> None: assert second["url"] == "https://configit.bamboohr.com/careers/37" assert second["department"] == "Marketing" and rows[0]["department"] == "" assert second["location"] == "København Ø" - assert second["remote"] == "hybrid" + assert second["remote"] == "2" assert (second["posted"], second["description"], second["salary_text"]) == (None, "", "") @pytest.mark.parametrize(("flag", "kind", "remote"), [ - (True, "0", "remote"), (None, "0", "onsite"), (None, "1", "remote"), (None, "2", "hybrid"), - (None, None, None), (False, "7", None)]) + (True, "0", True), (None, "0", "0"), (None, "1", "1"), (None, "2", "2"), + (None, None, None), (False, "7", "7")]) def test_remote_is_the_flag_then_the_location_type( - flag: bool | None, kind: str | None, remote: str | None) -> None: + flag: bool | None, kind: str | None, remote: bool | str | None) -> None: body = json.loads(_read("bamboohr.json")) body["result"][0] |= {"isRemote": flag, "locationType": kind} assert bamboohr.parse(json.dumps(body).encode(), "configit")[0]["remote"] == remote @@ -102,7 +102,7 @@ def test_detail_reads_the_text_the_date_and_the_country() -> None: assert found["posted"] == datetime(2026, 9, 23, tzinfo=UTC) assert found["location"] == "København Ø, Denmark" assert found["places"] == [{"text": "København Ø, Denmark", "remote": None}] - assert found["remote"] == "hybrid" + assert found["remote"] == "2" text = found["description"] assert text.startswith("Our Global Marketing Team is looking for") assert "Skills & Experience" in text and "&" not in text and "<" not in text @@ -144,11 +144,11 @@ def test_the_board_and_its_details_are_read_with_the_json_accept_on_the_detail() def test_the_role_states_one_place_and_the_employment() -> None: rows = bamboohr.parse(_read("bamboohr.json"), "configit") assert rows[1]["places"] == [{"text": "København Ø", "remote": None}] - assert rows[1]["employment"] == "full_time" + assert rows[1]["employment"] == "Full-Time" body = json.loads(_read("bamboohr.json")) body["result"][0] |= {"employmentStatusLabel": "Seasonal", "location": {"city": None}} first = bamboohr.parse(json.dumps(body).encode(), "configit")[0] - assert first["places"] == [] and "employment" not in first + assert first["places"] == [] and first["employment"] == "Seasonal" def test_it_declares_what_it_reads() -> None: diff --git a/tests/test_ats_deel.py b/tests/test_ats_deel.py index aa27f07..1bb1127 100644 --- a/tests/test_ats_deel.py +++ b/tests/test_ats_deel.py @@ -32,7 +32,7 @@ def test_rows_come_from_the_payload_with_descriptions_resolved() -> None: assert first["url"] == ("https://jobs.deel.com/klarna/job-details/" "21584046-56d5-44c4-8b18-7e15dc659827/overview") assert first["location"] == "Stockholm" and first["department"] == "Engineering" - assert first["remote"] == "onsite" + assert first["remote"] == "ON_SITE" assert first["description"].startswith("Klarna, briefly At Klarna") assert "<" not in first["description"] and "$" not in first["description"][:3] assert all(r["description"] for r in rows) @@ -41,18 +41,18 @@ def test_rows_come_from_the_payload_with_descriptions_resolved() -> None: "2026-09-07T12:33:38.484000+00:00" -def test_several_locations_are_joined_and_remote_uses_the_stores_words() -> None: +def test_several_locations_are_joined_and_remote_is_the_hosts_word() -> None: rows = {r["source_id"][:8]: r for r in deel.parse(PAGE, "klarna")} assert rows["a8be45ac"]["location"] == "Stockholm; London; Milan; Warsaw" - assert rows["f96bb9d4"]["remote"] == "remote" + assert rows["f96bb9d4"]["remote"] == "REMOTE" assert rows["f96bb9d4"]["location"] == "Ohio" # Every place is kept, in the host's order; the work arrangement is the # places' remote flag. assert rows["a8be45ac"]["places"] == [ {"text": name, "remote": False} for name in ("Stockholm", "London", "Milan", "Warsaw")] assert rows["f96bb9d4"]["places"] == [{"text": "Ohio", "remote": True}] - assert rows["f96bb9d4"]["employment"] == "contract" # "Consultant" - assert rows["21584046"]["employment"] == "full_time" + assert rows["f96bb9d4"]["employment"] == "Consultant" + assert rows["21584046"]["employment"] == "Full-time" def test_pay_is_only_text_since_the_period_is_not_stated() -> None: diff --git a/tests/test_ats_eightfold.py b/tests/test_ats_eightfold.py index ad70888..8efb46f 100644 --- a/tests/test_ats_eightfold.py +++ b/tests/test_ats_eightfold.py @@ -87,8 +87,8 @@ def test_a_page_becomes_rows() -> None: @pytest.mark.parametrize(("option", "remote"), [ - ("onsite", "onsite"), ("hybrid", "hybrid"), ("remote", "remote"), (None, None), ("odd", None)]) -def test_the_work_location_option_maps_to_the_remote_words( + ("onsite", "onsite"), ("Hybrid", "Hybrid"), (None, None), ("odd", "odd"), (" ", None)]) +def test_the_work_location_option_is_the_hosts_word( option: str | None, remote: str | None) -> None: assert eightfold.rows([_position(1) | {"workLocationOption": option}], SLUG)[0]["remote"] == remote diff --git a/tests/test_ats_gem.py b/tests/test_ats_gem.py index eeed4e5..97395ca 100644 --- a/tests/test_ats_gem.py +++ b/tests/test_ats_gem.py @@ -55,7 +55,7 @@ def test_a_listing_becomes_rows() -> None: assert first["source_id"] == "8080046002" # numeric, from a synced Greenhouse assert first["title"] == "Staff AI Product Engineer (Prague/Brno/Remote EU)" assert first["url"] == "https://jobs.gem.com/productboard/8080046002" - assert first["department"] == "Product Engineering" and first["remote"] == "hybrid" + assert first["department"] == "Product Engineering" and first["remote"] == "HYBRID" assert first["location"] == "Prague" assert (first["posted"], first["description"], first["salary_text"]) == (None, "", "") assert backend["source_id"] == "am9icG9zdDqWC1V_RM7U6ORvTd1Iu64r" # opaque @@ -64,16 +64,16 @@ def test_a_listing_becomes_rows() -> None: assert backend["places"] == [{"text": "Prague", "remote": False}, {"text": "Remote Europe", "remote": True}, {"text": "Brno", "remote": False}] - assert first["employment"] == "full_time" + assert first["employment"] == "FULL_TIME" assert len({r["source_id"] for r in rows}) == 11 @pytest.mark.parametrize(("kind", "flags", "remote"), [ - ("IN_OFFICE", [False], "onsite"), ("HYBRID", [True], "hybrid"), ("REMOTE", [False], "remote"), - (None, [True, True], "remote"), (None, [True, False], None), (None, [], None), - ("SOMETHING_NEW", [False], None)]) + ("IN_OFFICE", [False], "IN_OFFICE"), ("HYBRID", [True], "HYBRID"), ("REMOTE", [False], "REMOTE"), + (None, [True, True], True), (None, [True, False], None), (None, [], None), + ("SOMETHING_NEW", [False], "SOMETHING_NEW")]) def test_remote_is_the_location_type_then_the_locations( - kind: str | None, flags: list[bool], remote: str | None) -> None: + kind: str | None, flags: list[bool], remote: bool | str | None) -> None: posting = {"extId": "1", "title": "Role", "job": {"locationType": kind}, "locations": [{"city": "X", "isRemote": f} for f in flags]} assert gem.rows([posting], "acme")[0]["remote"] == remote diff --git a/tests/test_ats_hibob.py b/tests/test_ats_hibob.py index 02d03c2..c73dded 100644 --- a/tests/test_ats_hibob.py +++ b/tests/test_ats_hibob.py @@ -51,7 +51,7 @@ def test_a_board_of_general_applications_reads_as_it_is() -> None: rows = hibob.parse(DIXA, "dixa") assert [(r["title"], r["location"], r["remote"]) for r in rows] == [ ("Expression of interest", "Copenhagen, Denmark", "hybrid"), - ("Expression of interest", "London, United Kingdom", "onsite")] + ("Expression of interest", "London, United Kingdom", "on_site")] assert rows[1]["description"].startswith("We're always excited") @@ -153,10 +153,10 @@ def test_each_ad_names_one_site_and_the_host_lists_a_copy_per_site() -> None: assert len({r["source_id"] for r in dixa}) == 2 -def test_the_employment_type_is_mapped_and_a_permanent_one_is_left_unmapped() -> None: +def test_the_employment_type_is_the_hosts_word() -> None: rows = hibob.parse(BOARD, "liquidia") - assert rows[0]["employment"] == "full_time" # "Regular Full Time" - assert "employment" not in hibob.parse(DIXA, "dixa")[0] # "Permanent" + assert rows[0]["employment"] == "Regular Full Time" + assert hibob.parse(DIXA, "dixa")[0]["employment"] == "Permanent" def test_it_declares_copies_with_a_page_and_a_robots_decision() -> None: diff --git a/tests/test_ats_jibe.py b/tests/test_ats_jibe.py index 4bb7999..0b03125 100644 --- a/tests/test_ats_jibe.py +++ b/tests/test_ats_jibe.py @@ -57,7 +57,7 @@ def test_a_page_becomes_rows() -> None: "Manchester, United Kingdom"] assert "country" not in several assert first["places"] == [{"text": "Bucharest, Romania", "remote": None}] - assert (first["country"], first["employment"]) == ("RO", "full_time") + assert (first["country"], first["employment"]) == ("RO", "FULL_TIME") assert all(r["description"] and "<" not in r["description"] and " " not in r["description"] for r in rows) diff --git a/tests/test_ats_jobylon.py b/tests/test_ats_jobylon.py index 90780a3..b744334 100644 --- a/tests/test_ats_jobylon.py +++ b/tests/test_ats_jobylon.py @@ -14,7 +14,6 @@ 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 Ask, jobylon # noqa: E402 @@ -36,20 +35,20 @@ def test_rows_come_from_the_embeds_literal() -> None: assert first["location"] == "Stockholm" assert first["places"] == [{"text": "Stockholm", "remote": None}] assert first["department"] == "Accounting & Finance" # `&` read as `&` - assert first["remote"] == "hybrid" + assert first["remote"] == "Hybrid" assert first["description"] == "" and first["salary_text"] == "" # A day, with no time of day: the embed says "Sept. 25, 2026". assert first["posted"] is not None and first["posted"].isoformat() == \ "2026-09-25T00:00:00+00:00" -def test_places_department_and_remote_follow_the_embeds_words() -> None: +def test_places_department_and_remote_are_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" + assert rows["382124"]["remote"] == "Remote" + assert rows["382860"]["remote"] == "On-site" assert rows["380347"]["remote"] is None # a role with no workspace @@ -130,18 +129,14 @@ def test_an_empty_board_is_no_roles() -> None: assert jobylon.parse(EMPTY, "1056") == [] -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") +def test_the_experience_and_the_employment_type_are_the_hosts_words() -> None: 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()) + assert rows["384238"]["seniority"] == "Mid level" + assert rows["385191"]["seniority"] == "Experienced" + assert rows["385191"]["employment"] == "Full-time" 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"] == "internship" + assert rows["502"]["seniority"] == "Student" and rows["502"]["employment"] == "Internship" def test_a_summary_is_the_teaser_unless_the_embed_says_none() -> None: diff --git a/tests/test_ats_lever.py b/tests/test_ats_lever.py index d8cbe27..1b4a2af 100644 --- a/tests/test_ats_lever.py +++ b/tests/test_ats_lever.py @@ -28,9 +28,9 @@ def test_the_country_is_only_taken_for_a_role_at_one_place() -> None: assert "country" not in several and one["country"] == "DE" -def test_the_commitment_is_mapped_and_a_permanent_one_is_left_unmapped() -> None: +def test_the_commitment_is_the_hosts_word() -> None: several, one = lever.parse(BOARD, "acme") - assert several["employment"] == "full_time" and "employment" not in one + assert several["employment"] == "Full-time" and one["employment"] == "Permanent" def test_it_declares_a_whole_listing_of_trusted_dates_and_no_robots_check() -> None: diff --git a/tests/test_prep_hosts_ashby.py b/tests/test_prep_hosts_ashby.py new file mode 100644 index 0000000..218db69 --- /dev/null +++ b/tests/test_prep_hosts_ashby.py @@ -0,0 +1,37 @@ +"""The ashby words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.ashby") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['REMOTE', 'EMPLOYMENT']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('remote', 'remote'), ('hybrid', 'hybrid'), ('onsite', 'onsite')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('fulltime', 'full_time'), ('parttime', 'part_time'), ('intern', 'internship'), ('contract', 'contract'), ('temporary', 'temporary')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_prep_hosts_bamboohr.py b/tests/test_prep_hosts_bamboohr.py new file mode 100644 index 0000000..66cf013 --- /dev/null +++ b/tests/test_prep_hosts_bamboohr.py @@ -0,0 +1,37 @@ +"""The bamboohr words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.bamboohr") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['EMPLOYMENT', 'REMOTE']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('0', 'onsite'), ('1', 'remote'), ('2', 'hybrid')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('full-time', 'full_time'), ('part time', 'part_time'), ('intern', 'internship'), ('contractor', 'contract')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_prep_hosts_deel.py b/tests/test_prep_hosts_deel.py new file mode 100644 index 0000000..518ebae --- /dev/null +++ b/tests/test_prep_hosts_deel.py @@ -0,0 +1,37 @@ +"""The deel words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.deel") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['EMPLOYMENT', 'REMOTE']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('on_site', 'onsite'), ('hybrid', 'hybrid'), ('remote', 'remote')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('full-time', 'full_time'), ('consultant', 'contract'), ('internship', 'internship')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_prep_hosts_eightfold.py b/tests/test_prep_hosts_eightfold.py new file mode 100644 index 0000000..4d134c0 --- /dev/null +++ b/tests/test_prep_hosts_eightfold.py @@ -0,0 +1,32 @@ +"""The eightfold words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.eightfold") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['REMOTE']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('onsite', 'onsite'), ('on_site', 'onsite'), ('hybrid', 'hybrid'), ('remote', 'remote')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value diff --git a/tests/test_prep_hosts_gem.py b/tests/test_prep_hosts_gem.py new file mode 100644 index 0000000..c442a89 --- /dev/null +++ b/tests/test_prep_hosts_gem.py @@ -0,0 +1,37 @@ +"""The gem words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.gem") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['EMPLOYMENT', 'REMOTE']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('in_office', 'onsite'), ('hybrid', 'hybrid'), ('remote', 'remote')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('full_time', 'full_time'), ('contractor', 'contract'), ('intern', 'internship')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_prep_hosts_hibob.py b/tests/test_prep_hosts_hibob.py new file mode 100644 index 0000000..5a6a284 --- /dev/null +++ b/tests/test_prep_hosts_hibob.py @@ -0,0 +1,37 @@ +"""The hibob words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.hibob") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['EMPLOYMENT', 'REMOTE']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('remote', 'remote'), ('hybrid', 'hybrid'), ('on_site', 'onsite'), ('onsite', 'onsite')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('regular full time', 'full_time'), ('fixed term', 'temporary'), ('intern', 'internship')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_prep_hosts_jibe.py b/tests/test_prep_hosts_jibe.py new file mode 100644 index 0000000..e71a794 --- /dev/null +++ b/tests/test_prep_hosts_jibe.py @@ -0,0 +1,32 @@ +"""The jibe words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.jibe") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['EMPLOYMENT']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('full_time', 'full_time'), ('contractor', 'contract'), ('intern', 'internship')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_prep_hosts_jobylon.py b/tests/test_prep_hosts_jobylon.py new file mode 100644 index 0000000..ff11c61 --- /dev/null +++ b/tests/test_prep_hosts_jobylon.py @@ -0,0 +1,42 @@ +"""The jobylon words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.jobylon") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['SENIORITY', 'EMPLOYMENT', 'REMOTE']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('mid level', 'mid'), ('student', 'intern'), ('entry level', 'junior'), ('executive', 'exec'), ('not applicable', '')]) +def test_seniority_words(word: str, value: str) -> None: + assert hosts.SENIORITY[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('full-time', 'full_time'), ('consultant', 'contract'), ('summer job', 'temporary')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value + + +@pytest.mark.parametrize(("word", "value"), [('remote', 'remote'), ('hybrid', 'hybrid'), ('on-site', 'onsite')]) +def test_remote_words(word: str, value: str) -> None: + assert hosts.REMOTE[word] == value diff --git a/tests/test_prep_hosts_lever.py b/tests/test_prep_hosts_lever.py new file mode 100644 index 0000000..36105cb --- /dev/null +++ b/tests/test_prep_hosts_lever.py @@ -0,0 +1,32 @@ +"""The lever words, mapped to the app's vocabulary.""" + +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + +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 # noqa: E402 +from plugins.readers._shared import EMPLOYMENTS # noqa: E402 + +hosts = importlib.import_module("app.prep.hosts.lever") + +VOCABULARY = {"SENIORITY": models.SENIORITIES, "EMPLOYMENT": EMPLOYMENTS, "REMOTE": models.REMOTE} + + +@pytest.mark.parametrize("table", ['EMPLOYMENT']) +def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: str) -> None: + words = getattr(hosts, table) + assert all(key == key.strip().lower() for key in words) + assert set(words.values()) <= {*VOCABULARY[table], ""} + + +@pytest.mark.parametrize(("word", "value"), [('full-time', 'full_time'), ('fulltime', 'full_time'), ('intern', 'internship'), ('freelance', 'freelance')]) +def test_employment_words(word: str, value: str) -> None: + assert hosts.EMPLOYMENT[word] == value diff --git a/tests/test_readers_shared.py b/tests/test_readers_shared.py index 91b3474..9417710 100644 --- a/tests/test_readers_shared.py +++ b/tests/test_readers_shared.py @@ -24,10 +24,16 @@ from plugins.readers._shared import ( # noqa: E402 #: The module-level names a reader keeps its employment words in. _TABLES = ("_EMPLOYMENT", "_CONTRACT", "_SCHEDULE") +#: The readers of `ashby` to `lever` hand on the host's words; their tables +#: moved to `app/prep/hosts`. +_RAW = {"ashby", "bamboohr", "deel", "eightfold", "gem", "greenhouse", "hibob", "hrmanager", + "jibe", "jobylon", "lever"} + def test_every_employment_table_maps_into_the_shared_vocabulary() -> None: found = 0 for name, module in readers.READERS.items(): + assert not _RAW & {name} or not any(hasattr(module, t) for t in _TABLES), name for table_name in _TABLES: table = getattr(module, table_name, None) if table is None: @@ -36,7 +42,7 @@ def test_every_employment_table_maps_into_the_shared_vocabulary() -> None: values = table.values() if isinstance(table, dict) else [v for _k, v in table] # "" is a known word that names no employment ("permanent"). assert set(values) <= {*EMPLOYMENTS, ""}, (name, table_name) - assert found >= 15 + assert found >= 5 def test_the_vocabulary_is_the_documented_one() -> None: