Readers oracle to workday and the providers hand on the host's words; their word tables move to app/prep/hosts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 11:07:07 +02:00
1 parent a66aac95cf
commit 06eb929eaf
48 files changed
+460 -388

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
"""Oracle Recruiting Cloud's words, for prep."""
#: `WorkplaceTypeCode` -> `REMOTE`'s words. A role that states none has an
#: empty code, which stays unknown.
REMOTE = {"ora_remote": "remote", "ora_hybrid": "hybrid", "ora_on_site": "onsite"}
+11
View File
@@ -0,0 +1,11 @@
"""Personio's words, for prep."""
#: `seniority`. `experienced` is what most roles say and names no level.
SENIORITY = {"entry-level": "junior", "student": "intern", "executive": "exec",
"experienced": ""}
#: `employment` is the feed's `employmentType`, or, for a `permanent` one
#: (which says nothing about the hours), its `schedule`.
EMPLOYMENT = {"temporary": "temporary", "freelance": "contract", "intern": "internship",
"working_student": "internship", "trainee": "internship",
"permanent": "", "full-time": "full_time", "part-time": "part_time"}
+5
View File
@@ -0,0 +1,5 @@
"""Phenom's words, for prep."""
#: The words a page's `checkRemote` says (King's pages say "On-site"; no
#: other was seen).
REMOTE = {"remote": "remote", "hybrid": "hybrid", "on-site": "onsite", "onsite": "onsite"}
+12
View File
@@ -0,0 +1,12 @@
"""Pinpoint's words, for prep."""
#: `workplace_type`. Anything else says nothing.
REMOTE = {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid", "remote": "remote"}
#: What `employment_type` (`permanent_full_time`, `fixed_term_full_time`)
#: says, matched by fragment: the first fragment found in the lowercased
#: word decides, so a contract type beats the hours. The fixtures hold two
#: whole words only, so this is not turned into a whole-word table.
MATCH = [("intern", "internship"), ("freelance", "contract"), ("contract", "contract"),
("fixed_term", "temporary"), ("temporary", "temporary"),
("part_time", "part_time"), ("full_time", "full_time")]
+15
View File
@@ -0,0 +1,15 @@
"""Recruitee's words, for prep."""
#: `experience_code`. `experienced` names no level and is known, so it maps
#: to none.
SENIORITY = {"student_school": "intern", "entry_level": "junior", "mid_level": "mid",
"experienced": ""}
#: The words of `employment_type_code` (`fulltime_permanent`), which is
#: lowercased and split at "_" and "-"; the first entry found among its words
#: decides, so a contract type beats the hours. The fixtures hold three whole
#: codes only, so this is a table of words, not whole codes.
MATCH = [("internship", "internship"), ("intern", "internship"),
("freelance", "contract"), ("contract", "contract"),
("temporary", "temporary"), ("fixed", "temporary"),
("parttime", "part_time"), ("fulltime", "full_time")]
+8
View File
@@ -0,0 +1,8 @@
"""Rippling's words, for prep."""
#: The words of `employmentType.label` (`SALARIED_FT`), which is split at
#: "_" and the first token found here decides. The fixtures hold one whole
#: label only, so this is a table of tokens (lowercased), not whole words.
MATCH = [("ft", "full_time"), ("pt", "part_time"), ("intern", "internship"),
("internship", "internship"), ("contract", "contract"), ("contractor", "contract"),
("temp", "temporary"), ("temporary", "temporary"), ("seasonal", "temporary")]
+11
View File
@@ -0,0 +1,11 @@
"""SmartRecruiters' words, for prep."""
#: `experienceLevel.id`. The three in the middle name no level ("associate" is
#: half of Bosch's roles) and are known, so they map to none.
SENIORITY = {"internship": "intern", "entry_level": "junior", "director": "director",
"executive": "exec", "associate": "", "mid_senior_level": "",
"not_applicable": ""}
#: `typeOfEmployment.id`.
EMPLOYMENT = {"permanent": "", "intern": "internship", "temporary": "temporary",
"contract": "contract", "part_time": "part_time", "full_time": "full_time"}
+7
View File
@@ -0,0 +1,7 @@
"""Teamtailor's words, for prep."""
#: `remoteStatus`. `none` says nothing about where the role is worked and
#: `temporary` is remote for a spell only, so both are known and stay
#: unknown rather than become "onsite" or "remote".
REMOTE = {"fully": "remote", "hybrid": "hybrid", "onsite": "onsite",
"none": "", "temporary": ""}
+8
View File
@@ -0,0 +1,8 @@
"""Workable's words, for prep."""
#: `workplace`.
REMOTE = {"remote": "remote", "hybrid": "hybrid", "on_site": "onsite"}
#: `type`.
EMPLOYMENT = {"full": "full_time", "part": "part_time", "contract": "contract",
"temporary": "temporary", "internship": "internship"}
+10
View File
@@ -0,0 +1,10 @@
"""Workday's words, for prep."""
#: `remoteType`. Only some tenants send it, and each words it its own way
#: (Zendesk's "Fully Flexible", Axis' "On-Site"); a word not listed, a bare
#: "No" among them, says nothing and stays unknown.
REMOTE = {"remote": "remote", "fully flexible": "remote", "hybrid": "hybrid",
"in office": "onsite", "on-site": "onsite", "onsite": "onsite"}
#: `timeType`.
EMPLOYMENT = {"full time": "full_time", "part time": "part_time"}
+1 -2
View File
@@ -24,7 +24,7 @@ from urllib.parse import urlencode
from desk.sources import strip_html from desk.sources import strip_html
from ._contract import Ask, Fields, Filters, Key, Place, Reads from ._contract import Ask, Fields, Filters, Key, Place, Reads
from ._shared import Get, Page, Row, is_web_url, only, parse_dt, remote_word from ._shared import Get, Page, Row, is_web_url, only, parse_dt
NAME = "adzuna" NAME = "adzuna"
LABEL = "Adzuna" LABEL = "Adzuna"
@@ -124,7 +124,6 @@ def rows(decoded: Any, slug: str) -> list[Row]:
"places": places, "places": places,
"location": town, "location": town,
"country": country.upper(), "country": country.upper(),
"remote": remote_word(title),
"posted": parse_dt(job.get("created")), "posted": parse_dt(job.get("created")),
"teaser": _text(job.get("description") or ""), "teaser": _text(job.get("description") or ""),
"salary_min": None if predicted else job.get("salary_min"), "salary_min": None if predicted else job.get("salary_min"),
+2 -5
View File
@@ -28,7 +28,7 @@ from urllib.parse import urlencode
from desk.sources import strip_html from desk.sources import strip_html
from ._shared import Get, Page, Row, is_web_url, only, parse_dt, remote_word from ._shared import Get, Page, Row, is_web_url, only, parse_dt, place
from ._contract import Ask, Fields, Filters, Place, Reads from ._contract import Ask, Fields, Filters, Place, Reads
NAME = "jobindex" NAME = "jobindex"
@@ -131,9 +131,7 @@ def rows(decoded: Any, slug: str) -> list[Row]:
company = full_title[len(title) + 2:].strip() company = full_title[len(title) + 2:].strip()
area = _AREA.search(description) area = _AREA.search(description)
town = _text(area.group(1)) if area else decoded["area"] town = _text(area.group(1)) if area else decoded["area"]
remote = remote_word(f"{town} {title}") places: list[Place] = [place(town)] if town else []
places: list[Place] = [{"text": town, "remote": True if remote == "remote" else None}] \
if town else []
out.append({ out.append({
"source_id": item["id"], "source_id": item["id"],
"title": title or full_title, "title": title or full_title,
@@ -142,7 +140,6 @@ def rows(decoded: Any, slug: str) -> list[Row]:
"places": places, "places": places,
"location": town, "location": town,
"country": "DK", "country": "DK",
"remote": remote,
"posted": parse_dt(item["published"]), "posted": parse_dt(item["published"]),
"teaser": " ".join(_text(p) for p in _PARAGRAPHS.findall(description)), "teaser": " ".join(_text(p) for p in _PARAGRAPHS.findall(description)),
}) })
+8 -18
View File
@@ -35,7 +35,7 @@ from desk.sources import strip_html
from ._contract import Ask, Fields, Filters, Place, Reads from ._contract import Ask, Fields, Filters, Place, Reads
from ._countries import NAMES, code_of from ._countries import NAMES, code_of
from ._shared import Get, Page, Row, add_place, country_if_single, only, parse_dt from ._shared import Get, Page, Row, add_place, only, parse_dt
NAME = "oracle" NAME = "oracle"
LABEL = "Oracle Recruiting Cloud" LABEL = "Oracle Recruiting Cloud"
@@ -55,7 +55,7 @@ PATTERNS = (
READS = Reads( READS = Reads(
scope="board", listing="paged", page_size=200, text="detail", teaser=True, scope="board", listing="paged", page_size=200, text="detail", teaser=True,
complete="stated", places="many", filters=Filters(country="ids", remote="one"), complete="stated", places="many", filters=Filters(country="ids", remote="one"),
fields=Fields(posted="trusted", remote="stated", country="stated"), fields=Fields(posted="trusted", remote="stated"),
robots=("read: robots.txt allows /hcmUI/CandidateExperience/en/sites/<site>/jobs " robots=("read: robots.txt allows /hcmUI/CandidateExperience/en/sites/<site>/jobs "
"(checked 2026-09-29)"), "(checked 2026-09-29)"),
) )
@@ -71,11 +71,6 @@ PAGE_SIZE = 200
_HOST = r"[a-z0-9-]+(?:\.[a-z0-9-]+)*\.oraclecloud\.(?:com|eu)" _HOST = r"[a-z0-9-]+(?:\.[a-z0-9-]+)*\.oraclecloud\.(?:com|eu)"
_SLUG = re.compile(rf"({_HOST})/([A-Za-z0-9_-]+)", re.IGNORECASE) _SLUG = re.compile(rf"({_HOST})/([A-Za-z0-9_-]+)", re.IGNORECASE)
#: `WorkplaceTypeCode` -> `store._remote`'s words. A role that states none
#: has an empty code, which stays unknown.
_REMOTE = {"ora_remote": "remote", "ora_hybrid": "hybrid", "ora_on_site": "onsite"}
def _parts(slug: str) -> tuple[str, str]: def _parts(slug: str) -> tuple[str, str]:
"""`(host, site number)` of a slug that passed `slug_ok`.""" """`(host, site number)` of a slug that passed `slug_ok`."""
host, _, site = slug.partition("/") host, _, site = slug.partition("/")
@@ -189,18 +184,14 @@ def rows(search: dict[str, Any], slug: str) -> list[Row]:
# The id goes into a URL, and a listing is external content. # The id goes into a URL, and a listing is external content.
if not title or not re.fullmatch(r"[A-Za-z0-9_-]+", role_id): if not title or not re.fullmatch(r"[A-Za-z0-9_-]+", role_id):
continue continue
remote = _REMOTE.get(_text(role.get("WorkplaceTypeCode")).lower()) remote = _text(role.get("WorkplaceTypeCode")) or None
at_office = (remote or "").lower() in ("ora_hybrid", "ora_on_site")
places: list[Place] = [] places: list[Place] = []
codes: set[str] = set()
secondary = [s for s in role.get("secondaryLocations") or [] if isinstance(s, dict)] secondary = [s for s in role.get("secondaryLocations") or [] if isinstance(s, dict)]
for name, code in ((_text(role.get("PrimaryLocation")), for name in (_text(role.get("PrimaryLocation")),
_text(role.get("PrimaryLocationCountry"))), *(_text(s.get("Name")) for s in secondary)):
*((_text(s.get("Name")), _text(s.get("CountryCode"))) add_place(places, {"text": name, "remote": (
for s in secondary)): True if (remote or "").lower() == "ora_remote" else False if at_office else None)})
add_place(places, {"text": name, "remote": {"remote": True, "hybrid": False,
"onsite": False}.get(remote or "")})
if code:
codes.add(code.upper())
out.append({ out.append({
"source_id": role_id, "source_id": role_id,
"title": title, "title": title,
@@ -212,7 +203,6 @@ def rows(search: dict[str, Any], slug: str) -> list[Row]:
or _text(role.get("Department")) or _text(role.get("Organization"))), or _text(role.get("Department")) or _text(role.get("Organization"))),
"description": "", "description": "",
"teaser": _plain(role.get("ShortDescriptionStr")), "teaser": _plain(role.get("ShortDescriptionStr")),
"country": country_if_single(codes),
"remote": remote, "remote": remote,
"salary_text": "", # the resource states no pay "salary_text": "", # the resource states no pay
}) })
+9 -30
View File
@@ -7,16 +7,13 @@ Personio.
from __future__ import annotations from __future__ import annotations
import logging
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from collections.abc import Callable from collections.abc import Callable
from desk.sources import strip_html from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads from ._contract import Ask, Fields, Place, Reads
from ._shared import Row, add_place, label_slug_ok, num, only, parse_dt, pay_line, place, table_word, yearly_amount from ._shared import Row, add_place, label_slug_ok, num, only, parse_dt, pay_line, place, yearly_amount
log = logging.getLogger(__name__)
NAME = "personio" NAME = "personio"
LABEL = "Personio" LABEL = "Personio"
@@ -30,19 +27,6 @@ READS = Reads(
robots="api: no robots.txt check needed (public board API), 2026-09-30", robots="api: no robots.txt check needed (public board API), 2026-09-30",
) )
#: `seniority` -> the app's levels. `experienced` is what most roles say and
#: names no level, so it is known and maps to none; a word not listed is
#: logged at debug level so the table can grow.
_SENIORITY = {"entry-level": "junior", "student": "intern", "executive": "exec",
"experienced": ""}
#: `employmentType` when it is not the usual permanent contract, to the app's
#: employment words; `permanent` says nothing about the hours, so `schedule`
#: decides then.
_CONTRACT = {"temporary": "temporary", "freelance": "contract", "intern": "internship",
"working_student": "internship", "trainee": "internship"}
_SCHEDULE = {"full-time": "full_time", "part-time": "part_time"}
#: Personio's `salaryInformation/type` spellings, to the plain period word #: Personio's `salaryInformation/type` spellings, to the plain period word
#: `pay_line` wants ("yearly" -> "year"). Anything else is passed through. #: `pay_line` wants ("yearly" -> "year"). Anything else is passed through.
_PERIODS = {"yearly": "year", "monthly": "month", "hourly": "hour", _PERIODS = {"yearly": "year", "monthly": "month", "hourly": "hour",
@@ -85,18 +69,14 @@ def _salary_text(salary_info: ET.Element) -> str:
salary_info.findtext("currencyCode"), period) salary_info.findtext("currencyCode"), period)
def _seniority(word: str) -> str | None:
return table_word(_SENIORITY, word, log, "seniority")
def _employment(position: ET.Element) -> str | None: def _employment(position: ET.Element) -> str | None:
contract = (position.findtext("employmentType") or "").strip().lower() """The host's word for the contract, or, for a `permanent` one (which says
schedule = (position.findtext("schedule") or "").strip().lower() nothing about the hours), the `schedule`."""
if contract in _CONTRACT: contract = (position.findtext("employmentType") or "").strip()
return _CONTRACT[contract] schedule = (position.findtext("schedule") or "").strip()
if contract and contract != "permanent": if contract.lower() in ("", "permanent") and schedule:
log.debug("personio: unknown employmentType %r", contract) return schedule
return _SCHEDULE.get(schedule) return contract or None
def _places(position: ET.Element) -> list[Place]: def _places(position: ET.Element) -> list[Place]:
@@ -148,8 +128,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
"posted": parse_dt(position.findtext("createdAt")), "posted": parse_dt(position.findtext("createdAt")),
"department": (position.findtext("department") or "").strip(), "department": (position.findtext("department") or "").strip(),
"description": strip_html(description), "description": strip_html(description),
"remote": any(p["remote"] for p in places) or None, "seniority": (position.findtext("seniority") or "").strip() or None,
"seniority": _seniority(position.findtext("seniority") or ""),
"employment": _employment(position), "employment": _employment(position),
"salary_text": salary_text, "salary_text": salary_text,
"salary_min": salary_min, "salary_min": salary_min,
+3 -4
View File
@@ -188,10 +188,9 @@ def rows(search: dict[str, Any], slug: str) -> list[Row]:
_JSON_LD = re.compile(r"<script[^>]+application/ld\+json[^>]*>(.*?)</script>", re.S | re.I) _JSON_LD = re.compile(r"<script[^>]+application/ld\+json[^>]*>(.*?)</script>", re.S | re.I)
#: Where a page assigns its state, and the words its `checkRemote` says that #: Where a page assigns its state. Its `checkRemote` says "On-site" on King's
#: `store._remote` reads (King's pages say "On-site"; no other was seen). #: pages; no other word was seen.
_STATE = "phApp.ddo = " _STATE = "phApp.ddo = "
_REMOTE = {"remote": "remote", "hybrid": "hybrid", "on-site": "onsite", "onsite": "onsite"}
def _job_posting(body: str) -> dict[str, Any]: def _job_posting(body: str) -> dict[str, Any]:
@@ -243,6 +242,6 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
raise ValueError("no description on the role's page") raise ValueError("no description on the role's page")
if posted := parse_dt(posting.get("datePosted")): if posted := parse_dt(posting.get("datePosted")):
out["posted"] = posted out["posted"] = posted
if remote := _REMOTE.get(_text(job.get("checkRemote")).lower()): if remote := _text(job.get("checkRemote")):
out["remote"] = remote out["remote"] = remote
return out return out
+4 -26
View File
@@ -18,7 +18,6 @@ from __future__ import annotations
import html import html
import json import json
import logging
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any
@@ -27,8 +26,6 @@ from desk.sources import strip_html
from ._contract import Ask, Fields, Reads from ._contract import Ask, Fields, Reads
from ._shared import Row, is_web_url, label_slug_ok, num, only, pay_line, yearly_amount from ._shared import Row, is_web_url, label_slug_ok, num, only, pay_line, yearly_amount
log = logging.getLogger(__name__)
NAME = "pinpoint" NAME = "pinpoint"
LABEL = "Pinpoint" LABEL = "Pinpoint"
PATTERNS = (r"https?://([a-z0-9-]+)\.pinpointhq\.com",) PATTERNS = (r"https?://([a-z0-9-]+)\.pinpointhq\.com",)
@@ -39,9 +36,6 @@ READS = Reads(
robots="read: robots.txt allows / (checked 2026-09-29)", robots="read: robots.txt allows / (checked 2026-09-29)",
) )
#: `workplace_type` -> `store._remote`'s words. Anything else says nothing.
_REMOTE = {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid", "remote": "remote"}
#: `compensation_frequency` -> the multiplier that makes a figure yearly. The #: `compensation_frequency` -> the multiplier that makes a figure yearly. The
#: spellings are a guess, since no board read so far states pay; a frequency #: spellings are a guess, since no board read so far states pay; a frequency
#: not listed leaves the yearly columns empty, and `salary_text` still says it. #: not listed leaves the yearly columns empty, and `salary_text` still says it.
@@ -51,12 +45,6 @@ _YEARLY = {"annually": 1, "annual": 1, "yearly": 1, "year": 1, "monthly": 12, "m
_PERIOD = {"annually": "year", "annual": "year", "yearly": "year", "monthly": "month", _PERIOD = {"annually": "year", "annual": "year", "yearly": "year", "monthly": "month",
"weekly": "week", "daily": "day", "hourly": "hour"} "weekly": "week", "daily": "day", "hourly": "hour"}
#: What `employment_type` (`permanent_full_time`, `fixed_term_full_time`) says,
#: the first fragment found deciding, so a contract type beats the hours.
_EMPLOYMENT = (("intern", "internship"), ("freelance", "contract"), ("contract", "contract"),
("fixed_term", "temporary"), ("temporary", "temporary"),
("part_time", "part_time"), ("full_time", "full_time"))
#: The sections of a posting's text, in the order the page shows them: the #: The sections of a posting's text, in the order the page shows them: the
#: description, then these fields, each with its own heading in `<field>_header`. #: description, then these fields, each with its own heading in `<field>_header`.
_SECTIONS = ("key_responsibilities", "skills_knowledge_expertise", "benefits") _SECTIONS = ("key_responsibilities", "skills_knowledge_expertise", "benefits")
@@ -112,16 +100,6 @@ def _place(location: dict[str, Any]) -> str:
return ", ".join(parts) return ", ".join(parts)
def _employment(code: str) -> str | None:
code = code.strip().lower()
for fragment, value in _EMPLOYMENT:
if fragment in code:
return value
if code:
log.debug("pinpoint: unknown employment_type %r", code)
return None
def _pay(j: dict[str, Any]) -> tuple[int | None, int | None, str, str]: def _pay(j: dict[str, Any]) -> tuple[int | None, int | None, str, str]:
"""`(salary_min, salary_max, currency, salary_text)` of a posting whose """`(salary_min, salary_max, currency, salary_text)` of a posting whose
pay is shown (`compensation_visible`); the free-text `compensation` is the pay is shown (`compensation_visible`); the free-text `compensation` is the
@@ -154,21 +132,21 @@ def parse(body: bytes, slug: str) -> list[Row]:
continue continue
job = j.get("job") or {} job = j.get("job") or {}
low, high, currency, salary_text = _pay(j) low, high, currency, salary_text = _pay(j)
workplace = str(j.get("workplace_type") or "").strip().lower() workplace = str(j.get("workplace_type") or "").strip()
place = _place(j.get("location") or {}) place = _place(j.get("location") or {})
out.append({ out.append({
"source_id": source_id, "source_id": source_id,
"title": title, "title": title,
"places": [{"text": place, "remote": {"remote": True, "onsite": False, "places": [{"text": place, "remote": {"remote": True, "onsite": False,
"on_site": False, "hybrid": False}.get(workplace)}] "on_site": False, "hybrid": False}.get(workplace.lower())}]
if place else [], if place else [],
"location": place, "location": place,
"url": url, "url": url,
"posted": None, # only the posting's own page has a date "posted": None, # only the posting's own page has a date
"department": str((job.get("department") or {}).get("name") or "").strip(), "department": str((job.get("department") or {}).get("name") or "").strip(),
"description": _text(j), "description": _text(j),
"remote": _REMOTE.get(workplace), "remote": workplace or None,
"employment": _employment(str(j.get("employment_type") or "")), "employment": str(j.get("employment_type") or "").strip() or None,
"salary_text": salary_text, "salary_text": salary_text,
"salary_min": low, "salary_min": low,
"salary_max": high, "salary_max": high,
+5 -5
View File
@@ -7,8 +7,8 @@ Checked live on 2026-09-29 and 2026-09-30, moved here from `plugins/search.py`.
above 2000 is refused, so a search reads 2,100 results at most. It states above 2000 is refused, so a search reads 2,100 results at most. It states
`total`. A hit has the whole ad's text, so the list has the full text. An ad `total`. A hit has the whole ad's text, so the list has the full text. An ad
may name several workplaces: `workplace_addresses` holds one entry each, and may name several workplaces: `workplace_addresses` holds one entry each, and
every one is a place of the role. `workplace_model` is mostly empty, so every one is a place of the role. `workplace_model` is mostly empty; its
`remote` comes from the headline and the model together. label is passed on as `remote`, in the host's words.
""" """
from __future__ import annotations from __future__ import annotations
@@ -22,7 +22,7 @@ from urllib.parse import urlencode
from desk.sources import strip_html from desk.sources import strip_html
from ._contract import Ask, Fields, Filters, Place, Reads from ._contract import Ask, Fields, Filters, Place, Reads
from ._shared import Get, Page, Row, is_web_url, only, parse_dt, remote_word from ._shared import Get, Page, Row, is_web_url, only, parse_dt
NAME = "platsbanken" NAME = "platsbanken"
LABEL = "Platsbanken" LABEL = "Platsbanken"
@@ -113,7 +113,7 @@ def rows(decoded: Any, slug: str) -> list[Row]:
addresses = hit.get("workplace_addresses") or [hit.get("workplace_address") or {}] addresses = hit.get("workplace_addresses") or [hit.get("workplace_address") or {}]
places = [place for address in addresses if isinstance(address, dict) places = [place for address in addresses if isinstance(address, dict)
if (place := _place(address))] if (place := _place(address))]
model = (hit.get("workplace_model") or {}).get("label") or "" model = str((hit.get("workplace_model") or {}).get("label") or "").strip()
out.append({ out.append({
"source_id": str(hit.get("id") or ""), "source_id": str(hit.get("id") or ""),
"title": title, "title": title,
@@ -122,7 +122,7 @@ def rows(decoded: Any, slug: str) -> list[Row]:
"places": places, "places": places,
"location": places[0]["text"] if places else "", "location": places[0]["text"] if places else "",
"country": "SE", "country": "SE",
"remote": remote_word(f"{title} {model}"), "remote": model or None,
"posted": parse_dt(hit.get("publication_date")), "posted": parse_dt(hit.get("publication_date")),
"description": _text((hit.get("description") or {}).get("text") or ""), "description": _text((hit.get("description") or {}).get("text") or ""),
}) })
+8 -43
View File
@@ -8,16 +8,13 @@ Recruitee.
from __future__ import annotations from __future__ import annotations
import json import json
import logging
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any
from desk.sources import strip_html from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads from ._contract import Ask, Fields, Place, Reads
from ._shared import Row, add_place, country_if_single, is_web_url, label_slug_ok, num, only, parse_dt, pay_line, table_word, yearly_amount from ._shared import Row, add_place, is_web_url, label_slug_ok, num, only, parse_dt, pay_line, yearly_amount
log = logging.getLogger(__name__)
NAME = "recruitee" NAME = "recruitee"
LABEL = "Recruitee" LABEL = "Recruitee"
@@ -27,23 +24,11 @@ PATTERNS = (r"https?://([a-z0-9-]+)\.recruitee\.com",)
READS = Reads( READS = Reads(
scope="board", listing="whole", text="listing", complete="whole", scope="board", listing="whole", text="listing", complete="whole",
places="many", places="many",
fields=Fields(pay="figures", posted="trusted", remote="stated", country="stated", fields=Fields(pay="figures", posted="trusted", remote="stated",
seniority="stated", employment="stated"), seniority="stated", employment="stated"),
robots="api: no robots.txt check needed (public board API), 2026-09-30", robots="api: no robots.txt check needed (public board API), 2026-09-30",
) )
#: `experience_code` -> the app's levels. `experienced` names no level and is
#: known, so it maps to none; a word not listed is logged at debug level.
_SENIORITY = {"student_school": "intern", "entry_level": "junior", "mid_level": "mid",
"experienced": ""}
#: The words of `employment_type_code` (`fulltime_permanent`), the first that
#: is found deciding, so a contract type beats the hours.
_EMPLOYMENT = (("internship", "internship"), ("intern", "internship"),
("freelance", "contract"), ("contract", "contract"),
("temporary", "temporary"), ("fixed", "temporary"),
("parttime", "part_time"), ("fulltime", "full_time"))
#: What the board writes as a place for a role that is worked anywhere. #: What the board writes as a place for a role that is worked anywhere.
_NO_PLACE = ("remote job",) _NO_PLACE = ("remote job",)
@@ -82,28 +67,13 @@ def _salary_text(salary: dict[str, Any]) -> str:
salary.get("currency"), period) salary.get("currency"), period)
def _seniority(code: str) -> str | None: def _places(offer: dict[str, Any]) -> list[Place]:
return table_word(_SENIORITY, code, log, "experience_code") """Every place of an offer. `locations`
def _employment(code: str) -> str | None:
words = set(code.strip().lower().replace("-", "_").split("_"))
for word, value in _EMPLOYMENT:
if word in words:
return value
if code.strip():
log.debug("recruitee: unknown employment_type_code %r", code)
return None
def _places(offer: dict[str, Any]) -> tuple[list[Place], set[str]]:
"""Every place of an offer and the countries' codes among them. `locations`
lists them (city, state, country), `location` is the first as one line and lists them (city, state, country), `location` is the first as one line and
is the fallback for an offer that lists none. The board writes "Remote is the fallback for an offer that lists none. The board writes "Remote
job" where an offer has no place: that is not one, and a remote offer with job" where an offer has no place: that is not one, and a remote offer with
no other place has the place "Remote".""" no other place has the place "Remote"."""
found: list[Place] = [] found: list[Place] = []
codes: set[str] = set()
def add(text: str) -> None: def add(text: str) -> None:
text = text.strip() text = text.strip()
@@ -119,15 +89,11 @@ def _places(offer: dict[str, Any]) -> tuple[list[Place], set[str]]:
if part and part not in parts: if part and part not in parts:
parts.append(part) parts.append(part)
add(", ".join(parts)) add(", ".join(parts))
if code := str(loc.get("country_code") or "").strip().upper():
codes.add(code)
if not found: if not found:
add(str(offer.get("location") or offer.get("city") or "")) add(str(offer.get("location") or offer.get("city") or ""))
if code := str(offer.get("country_code") or "").strip().upper():
codes.add(code)
if not found and offer.get("remote"): if not found and offer.get("remote"):
found.append({"text": "Remote", "remote": True}) found.append({"text": "Remote", "remote": True})
return found, codes return found
def parse(body: bytes, slug: str) -> list[Row]: def parse(body: bytes, slug: str) -> list[Row]:
@@ -145,7 +111,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
salary_min, salary_max, currency = yearly_amount( salary_min, salary_max, currency = yearly_amount(
salary.get("min"), salary.get("max"), salary.get("currency"), salary.get("min"), salary.get("max"), salary.get("currency"),
salary.get("period"), {"year": 1, "month": 12}) salary.get("period"), {"year": 1, "month": 12})
places, codes = _places(j) places = _places(j)
rows.append({ rows.append({
"source_id": str(j.get("id") or ""), "source_id": str(j.get("id") or ""),
"title": title, "title": title,
@@ -160,8 +126,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
"salary_min": salary_min, "salary_min": salary_min,
"salary_max": salary_max, "salary_max": salary_max,
"currency": currency, "currency": currency,
"country": country_if_single(codes), "seniority": str(j.get("experience_code") or "").strip() or None,
"seniority": _seniority(str(j.get("experience_code") or "")), "employment": str(j.get("employment_type_code") or "").strip() or None,
"employment": _employment(str(j.get("employment_type_code") or "")),
}) })
return rows return rows
+3 -19
View File
@@ -12,7 +12,6 @@ from __future__ import annotations
import html import html
import json import json
import logging
import re import re
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any
@@ -22,8 +21,6 @@ from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads from ._contract import Ask, Fields, Place, Reads
from ._shared import Get, Row, add_place, parse_dt, yearly_amount from ._shared import Get, Row, add_place, parse_dt, yearly_amount
log = logging.getLogger(__name__)
NAME = "rippling" NAME = "rippling"
LABEL = "Rippling" LABEL = "Rippling"
KEEP_CASE = True KEEP_CASE = True
@@ -46,11 +43,6 @@ _SITE = "ats.rippling.com"
#: whole; it is also what discovery's patterns take. #: whole; it is also what discovery's patterns take.
_SLUG = re.compile(r"[A-Za-z0-9][A-Za-z0-9_-]*") _SLUG = re.compile(r"[A-Za-z0-9][A-Za-z0-9_-]*")
#: The words of `employmentType.label` (`SALARIED_FT`), split at "_".
_EMPLOYMENT = {"FT": "full_time", "PT": "part_time", "INTERN": "internship",
"INTERNSHIP": "internship", "CONTRACT": "contract", "CONTRACTOR": "contract",
"TEMP": "temporary", "TEMPORARY": "temporary", "SEASONAL": "temporary"}
#: A role's id in the board's own links. #: A role's id in the board's own links.
_UUID = re.compile(r"[0-9A-Za-z-]{8,64}") _UUID = re.compile(r"[0-9A-Za-z-]{8,64}")
@@ -86,8 +78,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
role and place, so a role in three cities is three entries with one role and place, so a role in three cities is three entries with one
`uuid` (Rippling's own board: 638 entries, 326 roles); the rows merge `uuid` (Rippling's own board: 638 entries, 326 roles); the rows merge
them, the places kept as a list and joined with "; " for `location`. The entry has no description, date them, the places kept as a list and joined with "; " for `location`. The entry has no description, date
or pay: `detail` reads them. `remote` is True only when every place is a or pay: `detail` reads them."""
"Remote (...)" one, since a label says nothing else about the work."""
data = json.loads(body) data = json.loads(body)
if not isinstance(data, list): if not isinstance(data, list):
raise ValueError("not a Rippling board: the answer is not a list") raise ValueError("not a Rippling board: the answer is not a list")
@@ -114,19 +105,12 @@ def parse(body: bytes, slug: str) -> list[Row]:
for job_id, row in roles.items(): for job_id, row in roles.items():
row["places"] = places[job_id] row["places"] = places[job_id]
row["location"] = "; ".join(p["text"] for p in places[job_id]) row["location"] = "; ".join(p["text"] for p in places[job_id])
row["remote"] = True if places[job_id] and all(
p["remote"] for p in places[job_id]) else None
return list(roles.values()) return list(roles.values())
def _employment(kind: Any) -> str | None: def _employment(kind: Any) -> str | None:
label = str((kind or {}).get("label") or "").strip().upper() if isinstance(kind, dict) else "" """The host's `employmentType.label` (`SALARIED_FT`), as given."""
for word in label.split("_"): return (str(kind.get("label") or "").strip() or None) if isinstance(kind, dict) else None
if word in _EMPLOYMENT:
return _EMPLOYMENT[word]
if label:
log.debug("rippling: unknown employmentType %r", label)
return None
def detail(get: Get, slug: str, row: Row) -> dict[str, Any]: def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
+7 -23
View File
@@ -13,15 +13,12 @@ ignores a remote parameter, so remote is not filtered.
from __future__ import annotations from __future__ import annotations
import json import json
import logging
import re import re
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any
from ._contract import Ask, Fields, Filters, Place, Reads from ._contract import Ask, Fields, Filters, Place, Reads
from ._shared import Get, Page, Row, only, parse_dt, path_slug_ok, table_word from ._shared import Get, Page, Row, only, parse_dt, path_slug_ok
log = logging.getLogger(__name__)
NAME = "smartrecruiters" NAME = "smartrecruiters"
LABEL = "SmartRecruiters" LABEL = "SmartRecruiters"
@@ -41,17 +38,6 @@ READS = Reads(
_API = "api.smartrecruiters.com" _API = "api.smartrecruiters.com"
#: `experienceLevel.id` -> the app's levels. The three in the middle name no
#: level ("associate" is half of Bosch's roles) and are known, so they map to
#: none; an id not listed is logged at debug level.
_SENIORITY = {"internship": "intern", "entry_level": "junior", "director": "director",
"executive": "exec", "associate": "", "mid_senior_level": "",
"not_applicable": ""}
#: `typeOfEmployment.id` -> the app's employment words.
_EMPLOYMENT = {"permanent": "", "intern": "internship", "temporary": "temporary",
"contract": "contract", "part_time": "part_time", "full_time": "full_time"}
#: The page size asked for, which is also the most the host serves per page. #: The page size asked for, which is also the most the host serves per page.
PAGE_SIZE = 100 PAGE_SIZE = 100
@@ -94,10 +80,9 @@ def parse(body: bytes, slug: str) -> list[Row]:
return rows(json.loads(body), slug) return rows(json.loads(body), slug)
def _word(job: dict[str, Any], key: str, table: dict[str, str]) -> str | None: def _word(job: dict[str, Any], key: str) -> str | None:
"""The `id` of the object `job[key]` looked up in `table`; none for a word """The `id` of the object `job[key]`, as given."""
the table maps to none, and a word it does not know is logged.""" return str((job.get(key) or {}).get("id") or "").strip() or None
return table_word(table, (job.get(key) or {}).get("id"), log, key)
def rows(data: dict[str, Any], slug: str) -> list[Row]: def rows(data: dict[str, Any], slug: str) -> list[Row]:
@@ -122,7 +107,6 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
loc_text = ", ".join(part.strip() for part in (loc_text or "").split(",") loc_text = ", ".join(part.strip() for part in (loc_text or "").split(",")
if part.strip()) if part.strip())
place: Place = {"text": loc_text, "remote": location.get("remote")} place: Place = {"text": loc_text, "remote": location.get("remote")}
country = str(location.get("country") or "").strip().upper()
out.append({ out.append({
"source_id": job_id, "source_id": job_id,
"title": title, "title": title,
@@ -134,8 +118,8 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
"description": "", "description": "",
"remote": location.get("remote"), "remote": location.get("remote"),
"salary_text": "", # SmartRecruiters' list endpoint states no pay at all "salary_text": "", # SmartRecruiters' list endpoint states no pay at all
"country": country if len(country) == 2 else None, "country": str(location.get("country") or "").strip() or None,
"seniority": _word(j, "experienceLevel", _SENIORITY), "seniority": _word(j, "experienceLevel"),
"employment": _word(j, "typeOfEmployment", _EMPLOYMENT), "employment": _word(j, "typeOfEmployment"),
}) })
return out return out
+3 -19
View File
@@ -59,7 +59,7 @@ from desk.sources import strip_html
from ._contract import Ask, Fields, Filters, Place, Reads from ._contract import Ask, Fields, Filters, Place, Reads
from ._countries import NAMES from ._countries import NAMES
from ._shared import Get, Page, Row, add_place, country_if_single, is_web_url, only, parse_dt from ._shared import Get, Page, Row, add_place, is_web_url, only, parse_dt
NAME = "successfactors" NAME = "successfactors"
LABEL = "SuccessFactors" LABEL = "SuccessFactors"
@@ -86,7 +86,7 @@ KEEP_CASE = True
READS = Reads( READS = Reads(
scope="board", listing="paged", text="detail", complete="stated", places="many", scope="board", listing="paged", text="detail", complete="stated", places="many",
filters=Filters(country="one"), filters=Filters(country="one"),
fields=Fields(posted="trusted", country="stated"), fields=Fields(posted="trusted"),
robots="read: robots.txt allows /search/ and /job/ (checked 2026-09-29)", robots="read: robots.txt allows /search/ and /job/ (checked 2026-09-29)",
) )
@@ -342,19 +342,6 @@ def _posted(value: str) -> datetime | None:
return parse_dt(value) return parse_dt(value)
def _country_code(meta: dict[str, str]) -> str:
"""The address's country as an ISO code: `addressCountry`, or the code that
`_place` reads in a `streetAddress`; '' for neither."""
code = meta.get("addressCountry", "").strip().upper()
if len(code) == 2:
return code
parts = [part.strip() for part in meta.get("streetAddress", "").split(",")]
for i in range(len(parts) - 1, 0, -1):
if len(parts) - i <= 2 and parts[i] in _COUNTRIES:
return parts[i]
return ""
def _location(meta: dict[str, str]) -> str: def _location(meta: dict[str, str]) -> str:
"""The address as "City, Country". Vestas and Demant state """The address as "City, Country". Vestas and Demant state
`addressLocality` and `addressCountry` (a code), the other sites one `addressLocality` and `addressCountry` (a code), the other sites one
@@ -373,7 +360,7 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
"""A role's own page: `description` from the block marked """A role's own page: `description` from the block marked
`itemprop="description"`, which Novo Nordisk's pages have without the `itemprop="description"`, which Novo Nordisk's pages have without the
microdata around it, and, from a page that has the `JobPosting` microdata, microdata around it, and, from a page that has the `JobPosting` microdata,
`posted` (`datePosted`) and every place with the country's code. A page that `posted` (`datePosted`) and every place. A page that
is not a role's (the site answers 200 for a closed one with its search) has is not a role's (the site answers 200 for a closed one with its search) has
no description block and gives an empty answer.""" no description block and gives an empty answer."""
text = get(row["url"]).decode("utf-8", "replace") text = get(row["url"]).decode("utf-8", "replace")
@@ -396,9 +383,6 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
if places: if places:
out["places"] = places out["places"] = places
out["location"] = "; ".join(p["text"] for p in places) out["location"] = "; ".join(p["text"] for p in places)
codes = {_country_code(address) for address in addresses}
if code := country_if_single(codes):
out["country"] = code
return out return out
+1 -7
View File
@@ -51,12 +51,6 @@ _HOST = re.compile(r"[a-z0-9-]+(\.[a-z0-9-]+)*")
#: Teamtailor's own namespace in the feed, the `tt:` of `tt:locations`. #: Teamtailor's own namespace in the feed, the `tt:` of `tt:locations`.
_TT = "{https://teamtailor.com/locations}" _TT = "{https://teamtailor.com/locations}"
#: Teamtailor's `remoteStatus` -> `store._remote`'s words. `none` says nothing
#: about where the role is worked and `temporary` is remote for a spell only,
#: so both stay unknown rather than become "onsite" or "remote".
_REMOTE = {"fully": "remote", "hybrid": "hybrid", "onsite": "onsite"}
def site(slug: str) -> str: def site(slug: str) -> str:
"""The host a career site is served from: `acme` is acme.teamtailor.com, """The host a career site is served from: `acme` is acme.teamtailor.com,
and a slug with a dot is a site on the company's own domain, and a slug with a dot is a site on the company's own domain,
@@ -141,7 +135,7 @@ def rows(items: list[ET.Element], slug: str) -> list[Row]:
"department": ((item.findtext(f"{_TT}department") or "").strip() "department": ((item.findtext(f"{_TT}department") or "").strip()
or (item.findtext(f"{_TT}role") or "").strip()), or (item.findtext(f"{_TT}role") or "").strip()),
"description": html.unescape(strip_html(item.findtext("description") or "")), "description": html.unescape(strip_html(item.findtext("description") or "")),
"remote": _REMOTE.get(status), "remote": status or None,
"salary_text": "", # Teamtailor's feed states no pay at all "salary_text": "", # Teamtailor's feed states no pay at all
}) })
return out return out
+10 -21
View File
@@ -8,14 +8,11 @@ board with roles was seen; jobhunt-hq did not read Workable.
from __future__ import annotations from __future__ import annotations
import json import json
import logging
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any
from ._contract import Ask, Fields, Place, Reads from ._contract import Ask, Fields, Place, Reads
from ._shared import Get, Page, Row, add_place, country_if_single, only, parse_dt, path_slug_ok, table_word from ._shared import Get, Page, Row, add_place, only, parse_dt, path_slug_ok
log = logging.getLogger(__name__)
NAME = "workable" NAME = "workable"
LABEL = "Workable" LABEL = "Workable"
@@ -28,17 +25,12 @@ PATTERNS = (
READS = Reads( READS = Reads(
scope="board", listing="paged", page_size=10, text="none", complete="stated", scope="board", listing="paged", page_size=10, text="none", complete="stated",
places="many", places="many",
fields=Fields(posted="trusted", remote="stated", country="stated", employment="stated"), fields=Fields(posted="trusted", remote="stated", employment="stated"),
robots="api: no robots.txt check needed (public board API), 2026-09-30", robots="api: no robots.txt check needed (public board API), 2026-09-30",
) )
_API = "apply.workable.com" _API = "apply.workable.com"
#: `type` -> the app's employment words; a type not listed is logged at debug
#: level so the table can grow.
_EMPLOYMENT = {"full": "full_time", "part": "part_time", "contract": "contract",
"temporary": "temporary", "internship": "internship"}
# No probe: Workable's API sits behind a rate limit that a run of guesses # No probe: Workable's API sits behind a rate limit that a run of guesses
# trips, and a Workable site links its board plainly anyway. # trips, and a Workable site links its board plainly anyway.
@@ -67,13 +59,12 @@ def parse(body: bytes, slug: str) -> list[Row]:
return rows(json.loads(body), slug) return rows(json.loads(body), slug)
def _places(job: dict[str, Any], remote: bool) -> tuple[list[Place], set[str]]: def _places(job: dict[str, Any], remote: bool) -> list[Place]:
"""Every place of a role and the countries' codes among them. `locations` """Every place of a role. `locations`
lists them (city, region, country; `hidden` ones are stated too), and lists them (city, region, country; `hidden` ones are stated too), and
`location` is the first alone, the fallback for a role that lists none. `location` is the first alone, the fallback for a role that lists none.
A place is remote when the role is.""" A place is remote when the role is."""
found: list[Place] = [] found: list[Place] = []
codes: set[str] = set()
listed = [loc for loc in job.get("locations") or [] if isinstance(loc, dict)] listed = [loc for loc in job.get("locations") or [] if isinstance(loc, dict)]
for loc in listed or [job.get("location") or {}]: for loc in listed or [job.get("location") or {}]:
parts: list[str] = [] parts: list[str] = []
@@ -83,9 +74,7 @@ def _places(job: dict[str, Any], remote: bool) -> tuple[list[Place], set[str]]:
parts.append(part) parts.append(part)
text = ", ".join(parts) text = ", ".join(parts)
add_place(found, {"text": text, "remote": remote}) add_place(found, {"text": text, "remote": remote})
if code := str(loc.get("countryCode") or "").strip().upper(): return found
codes.add(code)
return found, codes
def rows(data: dict[str, Any], slug: str) -> list[Row]: def rows(data: dict[str, Any], slug: str) -> list[Row]:
@@ -104,8 +93,9 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
shortcode = (j.get("shortcode") or "").strip() shortcode = (j.get("shortcode") or "").strip()
if not title or not shortcode: if not title or not shortcode:
continue continue
remote = bool(j.get("remote")) or j.get("workplace") == "remote" workplace = str(j.get("workplace") or "").strip()
places, codes = _places(j, remote) remote = bool(j.get("remote")) or workplace == "remote"
places = _places(j, remote)
dept = j.get("department") or "" dept = j.get("department") or ""
if isinstance(dept, list): if isinstance(dept, list):
dept = ", ".join(d for d in dept if d) dept = ", ".join(d for d in dept if d)
@@ -118,9 +108,8 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
"posted": parse_dt(j.get("published")), "posted": parse_dt(j.get("published")),
"department": dept.strip(), "department": dept.strip(),
"description": "", "description": "",
"remote": remote, "remote": workplace or j.get("remote"),
"salary_text": "", # Workable's list endpoint states no pay at all "salary_text": "", # Workable's list endpoint states no pay at all
"country": country_if_single(codes), "employment": str(j.get("type") or "").strip() or None,
"employment": table_word(_EMPLOYMENT, j.get("type"), log, "type"),
}) })
return out return out
+18 -30
View File
@@ -29,7 +29,6 @@ from __future__ import annotations
import html import html
import json import json
import logging
import re import re
from collections.abc import Callable from collections.abc import Callable
from datetime import UTC, datetime, timedelta from datetime import UTC, datetime, timedelta
@@ -39,9 +38,7 @@ from desk.sources import strip_html
from ._contract import Ask, Fields, Filters, Place, Reads from ._contract import Ask, Fields, Filters, Place, Reads
from ._countries import code_of from ._countries import code_of
from ._shared import Get, Page, Row, add_place, only, parse_dt, table_word from ._shared import Get, Page, Row, add_place, only, parse_dt
log = logging.getLogger(__name__)
NAME = "workday" NAME = "workday"
LABEL = "Workday" LABEL = "Workday"
@@ -50,7 +47,7 @@ KEEP_CASE = True
READS = Reads( READS = Reads(
scope="board", listing="paged", page_size=20, ceiling=2000, text="detail", scope="board", listing="paged", page_size=20, ceiling=2000, text="detail",
complete="stated", places="many", filters=Filters(country="ids", remote="ids"), complete="stated", places="many", filters=Filters(country="ids", remote="ids"),
fields=Fields(posted="trusted", remote="stated", country="stated", employment="stated"), fields=Fields(posted="trusted", remote="stated", employment="stated"),
robots="read: robots.txt allows /<Site>/ (checked 2026-09-29)", robots="read: robots.txt allows /<Site>/ (checked 2026-09-29)",
) )
@@ -167,7 +164,7 @@ def facets(get: Get, slug: str) -> dict[str, dict[str, str]]:
"""The tenant's host ids, read off one page of one role: `country` maps """The tenant's host ids, read off one page of one role: `country` maps
an ISO code to `<facetParameter>=<id>` in the facet whose values are an ISO code to `<facetParameter>=<id>` in the facet whose values are
countries (most of them, `_COUNTRY_SHARE`; the one with most countries countries (most of them, `_COUNTRY_SHARE`; the one with most countries
when two are), and `remote` maps each facet value that `_REMOTE` reads as when two are), and `remote` maps each facet value that `_REMOTE_FACET` names as
remote ("Remote", "Fully Flexible"), in whatever facet, to its id. A remote ("Remote", "Fully Flexible"), in whatever facet, to its id. A
tenant with neither states no such dimension, and the runner then does tenant with neither states no such dimension, and the runner then does
not filter on it.""" not filter on it."""
@@ -184,7 +181,7 @@ def facets(get: Get, slug: str) -> dict[str, dict[str, str]]:
country = found country = found
for v in values: for v in values:
word = " ".join(str(v.get("descriptor") or "").split()) word = " ".join(str(v.get("descriptor") or "").split())
if v.get("id") and _remote(word) == "remote": if v.get("id") and word.lower() in _REMOTE_FACET:
remote[word.lower()] = f"{name}={v['id']}" remote[word.lower()] = f"{name}={v['id']}"
out: dict[str, dict[str, str]] = {} out: dict[str, dict[str, str]] = {}
if country: if country:
@@ -216,11 +213,14 @@ def _today() -> datetime:
return datetime.now(UTC).replace(hour=0, minute=0, second=0, microsecond=0) return datetime.now(UTC).replace(hour=0, minute=0, second=0, microsecond=0)
#: `remoteType` -> `store._remote`'s words. Only some tenants send it, and #: The `remoteType` words a facet names that mean remote, which the `remote`
#: each words it its own way (Zendesk's "Fully Flexible", Axis' "On-Site"); a #: filter looks for; the row keeps the host's word whatever it is (only some
#: word not listed, a bare "No" among them, says nothing and stays unknown. #: tenants send it, each in its own way: Zendesk's "Fully Flexible", Axis'
_REMOTE = {"remote": "remote", "fully flexible": "remote", "hybrid": "hybrid", #: "On-Site").
"in office": "onsite", "on-site": "onsite", "onsite": "onsite"} _REMOTE_FACET = ("remote", "fully flexible")
#: The words that put a role's places in an office, for their `remote` flag.
_OFFICE = ("hybrid", "in office", "on-site", "onsite")
def _requisition(posting: dict[str, Any], path: str) -> str: def _requisition(posting: dict[str, Any], path: str) -> str:
@@ -234,12 +234,10 @@ def _requisition(posting: dict[str, Any], path: str) -> str:
def _remote(value: Any) -> str | None: def _remote(value: Any) -> str | None:
return _REMOTE.get(str(value or "").strip().lower()) """The host's `remoteType`, as given."""
return str(value or "").strip() or None
#: `timeType` -> the app's employment words.
_EMPLOYMENT = {"full time": "full_time", "part time": "part_time"}
#: What `locationsText` says of a role at several places: "2 Locations". The #: What `locationsText` says of a role at several places: "2 Locations". The
#: places arrive with the role's own read. #: places arrive with the role's own read.
_COUNT = re.compile(r"\d+ locations?", re.I) _COUNT = re.compile(r"\d+ locations?", re.I)
@@ -259,8 +257,9 @@ def _place(text: Any, remote: str | None) -> Place | None:
if len(parts) > 1 and "," not in text and all(parts) \ if len(parts) > 1 and "," not in text and all(parts) \
and not parts[0].lower().startswith(("remote", "hybrid", "on-site", "onsite")): and not parts[0].lower().startswith(("remote", "hybrid", "on-site", "onsite")):
text = ", ".join(reversed(parts)) text = ", ".join(reversed(parts))
return {"text": text, "remote": {"remote": True, "hybrid": False, "onsite": False}.get( word = (remote or "").lower()
remote or "")} return {"text": text, "remote": True if word in _REMOTE_FACET
else False if word in _OFFICE else None}
def rows(decoded: dict[str, Any], slug: str) -> list[Row]: def rows(decoded: dict[str, Any], slug: str) -> list[Row]:
@@ -318,9 +317,7 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
if places := _places(posting, remote): if places := _places(posting, remote):
out["places"] = places out["places"] = places
out["location"] = "; ".join(p["text"] for p in places) out["location"] = "; ".join(p["text"] for p in places)
if len(places) == 1 and (code := _country_code(posting)): if employment := str(posting.get("timeType") or "").strip():
out["country"] = code
if employment := table_word(_EMPLOYMENT, posting.get("timeType"), log, "timeType"):
out["employment"] = employment out["employment"] = employment
if posted := parse_dt(posting.get("startDate")): if posted := parse_dt(posting.get("startDate")):
out["posted"] = posted out["posted"] = posted
@@ -329,15 +326,6 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
return out return out
def _country_code(posting: dict[str, Any]) -> str | None:
"""The role's country as an ISO code, from the requisition's location. The
code belongs to the main location only, so it is used for a role with one
place."""
country = (posting.get("jobRequisitionLocation") or {}).get("country") or {}
code = str(country.get("alpha2Code") or "").strip().upper()
return code if len(code) == 2 else None
def _places(posting: dict[str, Any], remote: str | None) -> list[Place]: def _places(posting: dict[str, Any], remote: str | None) -> list[Place]:
"""The main location and the additional ones, each once, which replace the """The main location and the additional ones, each once, which replace the
listing's "2 Locations". A single location that does not name its country listing's "2 Locations". A single location that does not name its country
+7 -6
View File
@@ -132,10 +132,10 @@ def test_workable_builds_the_job_url_and_reads_location_and_remote() -> None:
assert [r["source_id"] for r in rows] == ["6125026", "6125041"] assert [r["source_id"] for r in rows] == ["6125026", "6125041"]
assert rows[0]["url"] == "https://apply.workable.com/huggingface/j/DB4D7C0EC8/" assert rows[0]["url"] == "https://apply.workable.com/huggingface/j/DB4D7C0EC8/"
assert rows[0]["location"] == "France" assert rows[0]["location"] == "France"
assert rows[0]["remote"] is True assert rows[0]["remote"] == "remote"
assert rows[0]["department"] == "Product" assert rows[0]["department"] == "Product"
assert rows[1]["location"] == "Berlin, Germany" assert rows[1]["location"] == "Berlin, Germany"
assert rows[1]["remote"] is False assert rows[1]["remote"] == "hybrid"
assert rows[0]["description"] == "" # the list endpoint carries no text assert rows[0]["description"] == "" # the list endpoint carries no text
assert rows[0]["salary_text"] == "" # Workable's list endpoint states no pay at all assert rows[0]["salary_text"] == "" # Workable's list endpoint states no pay at all
@@ -173,8 +173,9 @@ def test_personio_builds_the_job_url_and_reads_cdata_description() -> None:
assert [r["source_id"] for r in rows] == ["6001", "6002", "6003"] assert [r["source_id"] for r in rows] == ["6001", "6002", "6003"]
assert rows[0]["url"] == "https://acme.jobs.personio.de/job/6001" assert rows[0]["url"] == "https://acme.jobs.personio.de/job/6001"
assert rows[0]["description"] == "Grow our pipeline." assert rows[0]["description"] == "Grow our pipeline."
assert rows[0]["remote"] is True # "Remote - Germany" assert rows[0]["places"][0]["remote"] is True # "Remote - Germany"
assert rows[1]["remote"] is None # "Munich" assert rows[1]["places"][0]["remote"] is None # "Munich"
assert "remote" not in rows[0] # the feed states none
def test_personio_reads_salary_information_when_present() -> None: def test_personio_reads_salary_information_when_present() -> None:
@@ -291,9 +292,9 @@ def test_teamtailor_joins_the_distinct_locations_for_country_of() -> None:
assert country_of(rows[0]["location"]) == "SE" assert country_of(rows[0]["location"]) == "SE"
def test_teamtailor_maps_remote_status_and_falls_back_to_role_for_department() -> None: def test_teamtailor_hands_on_remote_status_and_falls_back_to_role_for_department() -> None:
rows = ats._parse_teamtailor(TEAMTAILOR, "kry") rows = ats._parse_teamtailor(TEAMTAILOR, "kry")
assert [r["remote"] for r in rows] == ["hybrid", "remote", None] # none says nothing assert [r["remote"] for r in rows] == ["hybrid", "fully", "none"] # prep maps them
assert rows[1]["title"] == "Läkare" # trimmed assert rows[1]["title"] == "Läkare" # trimmed
assert rows[1]["department"] == "Software Development" assert rows[1]["department"] == "Software Development"
assert ats.classify(rows[1]["department"], "Sales Lead") == "sales" assert ats.classify(rows[1]["department"], "Sales Lead") == "sales"
+5 -5
View File
@@ -59,19 +59,19 @@ def test_the_locations_are_the_primary_and_the_secondary_ones() -> None:
assert rows[2]["location"] == "India" assert rows[2]["location"] == "India"
def test_every_place_is_kept_with_its_work_mode_and_the_countrys_code() -> None: def test_every_place_is_kept_with_its_work_mode() -> None:
rows = _rows() rows = _rows()
assert [p["text"] for p in rows[1]["places"]] == [ assert [p["text"] for p in rows[1]["places"]] == [
"Malaysia", "Philippines", "Indonesia", "Thailand"] "Malaysia", "Philippines", "Indonesia", "Thailand"]
assert [p["remote"] for p in rows[0]["places"]] == [False, False] # hybrid assert [p["remote"] for p in rows[0]["places"]] == [False, False] # hybrid
assert [p["remote"] for p in rows[4]["places"]] == [True] # remote assert [p["remote"] for p in rows[4]["places"]] == [True] # remote
assert [p["remote"] for p in rows[3]["places"]] == [None] # states none assert [p["remote"] for p in rows[3]["places"]] == [None] # states none
# One country when the places share one, none over several. assert all("country" not in r for r in rows) # prep derives it from the places
assert [r["country"] for r in rows] == [None, None, "IN", "DE", "US"]
def test_remote_follows_the_workplace_type_code() -> None: def test_remote_is_the_workplace_type_code_as_given() -> None:
assert [r["remote"] for r in _rows()] == ["hybrid", "hybrid", "onsite", None, "remote"] assert [r["remote"] for r in _rows()] == [
"ORA_HYBRID", "ORA_HYBRID", "ORA_ON_SITE", None, "ORA_REMOTE"]
def test_a_department_is_taken_where_a_tenant_fills_one() -> None: def test_a_department_is_taken_where_a_tenant_fills_one() -> None:
+5 -19
View File
@@ -3,17 +3,14 @@ No network: the fixtures are saved feeds."""
from __future__ import annotations from __future__ import annotations
import logging
import sys import sys
from pathlib import Path from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path: if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT)) sys.path.insert(0, str(ROOT))
from app.models import SENIORITIES # noqa: E402
from plugins.readers import Ask, personio # noqa: E402 from plugins.readers import Ask, personio # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "ats" FIXTURES = ROOT / "tests" / "fixtures" / "ats"
@@ -37,23 +34,12 @@ def test_additional_offices_are_places_of_the_role_each_once() -> None:
assert [p["text"] for p in first["places"]] == ["Remote - Germany", "Berlin", "Hamburg"] assert [p["text"] for p in first["places"]] == ["Remote - Germany", "Berlin", "Hamburg"]
assert [p["remote"] for p in first["places"]] == [True, None, None] assert [p["remote"] for p in first["places"]] == [True, None, None]
assert first["location"] == "Remote - Germany; Berlin; Hamburg" assert first["location"] == "Remote - Germany; Berlin; Hamburg"
assert first["remote"] is True # one of the places is remote assert "remote" not in first # the feed states none
assert _rows()[1]["places"] == [{"text": "Munich", "remote": None}] assert _rows()[1]["places"] == [{"text": "Munich", "remote": None}]
assert _rows()[1]["remote"] is None
def test_the_stated_level_and_employment_are_mapped() -> None: def test_the_stated_level_and_employment_are_the_hosts_words() -> None:
rows = _rows() rows = _rows()
assert [r["seniority"] for r in rows] == ["junior", "exec", "intern"] assert [r["seniority"] for r in rows] == ["entry-level", "executive", "student"]
# permanent + full-time; permanent + full-time; working student wins over part-time # permanent + full-time gives the schedule; a working student is the contract's word
assert [r["employment"] for r in rows] == ["full_time", "full_time", "internship"] assert [r["employment"] for r in rows] == ["full-time", "full-time", "working_student"]
def test_the_table_speaks_the_apps_vocabulary_and_a_new_word_is_logged(
caplog: pytest.LogCaptureFixture) -> None:
assert {v for v in personio._SENIORITY.values() if v} <= set(SENIORITIES)
with caplog.at_level(logging.DEBUG, logger=personio.__name__):
assert personio._seniority("wizard") is None
assert personio._seniority("experienced") is None # known, names no level
assert personio._seniority("") is None
assert [r.getMessage() for r in caplog.records] == ["personio: unknown seniority 'wizard'"]
+1 -1
View File
@@ -226,7 +226,7 @@ def test_detail_falls_back_to_the_page_state_where_there_is_no_job_posting() ->
got = phenom.detail(_get_of("phenom-detail-3.html", []), SLUG, row) got = phenom.detail(_get_of("phenom-detail-3.html", []), SLUG, row)
assert got["description"].startswith("Craft: Games Design & Production Job Description:") assert got["description"].startswith("Craft: Games Design & Production Job Description:")
assert "<" not in got["description"] and "&amp;" not in got["description"] assert "<" not in got["description"] and "&amp;" not in got["description"]
assert got["remote"] == "onsite" assert got["remote"] == "On-site"
assert "posted" not in got and set(got) <= set(ats.DETAIL_FIELDS) assert "posted" not in got and set(got) <= set(ats.DETAIL_FIELDS)
+2 -5
View File
@@ -161,9 +161,6 @@ def test_a_role_has_its_one_place_with_the_work_mode_of_the_role() -> None:
assert rows[0]["location"] == "Bucharest" assert rows[0]["location"] == "Bucharest"
def test_employment_is_read_from_the_type_and_an_unknown_one_is_left() -> None: def test_employment_is_the_hosts_type_as_given() -> None:
rows = pinpoint.parse((FIXTURES / "pinpoint.json").read_bytes(), "xeneta") rows = pinpoint.parse((FIXTURES / "pinpoint.json").read_bytes(), "xeneta")
assert [r["employment"] for r in rows] == ["full_time", "temporary"] assert [r["employment"] for r in rows] == ["permanent_full_time", "fixed_term_full_time"]
assert pinpoint._employment("permanent_part_time") == "part_time"
assert pinpoint._employment("internship") == "internship"
assert pinpoint._employment("something_new") is None
+9 -25
View File
@@ -4,17 +4,14 @@ bunq's board, read on 2026-09-30."""
from __future__ import annotations from __future__ import annotations
import logging
import sys import sys
from pathlib import Path from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path: if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT)) sys.path.insert(0, str(ROOT))
from app.models import SENIORITIES # noqa: E402
from plugins.readers import Ask, recruitee # noqa: E402 from plugins.readers import Ask, recruitee # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "ats" FIXTURES = ROOT / "tests" / "fixtures" / "ats"
@@ -27,19 +24,18 @@ def _rows() -> list[dict]:
def test_the_declaration_says_what_the_feed_gives() -> None: def test_the_declaration_says_what_the_feed_gives() -> None:
reads = recruitee.READS reads = recruitee.READS
assert (reads.listing, reads.places, reads.text) == ("whole", "many", "listing") assert (reads.listing, reads.places, reads.text) == ("whole", "many", "listing")
assert reads.fields.posted == "trusted" and reads.fields.country == "stated" assert reads.fields.posted == "trusted" and reads.fields.country == "none"
assert reads.robots.startswith("api: no robots.txt check needed") assert reads.robots.startswith("api: no robots.txt check needed")
assert recruitee.feed_url("acme", Ask()) == "https://acme.recruitee.com/api/offers/" assert recruitee.feed_url("acme", Ask()) == "https://acme.recruitee.com/api/offers/"
def test_every_location_is_a_place_and_the_country_is_stated_when_they_share_one() -> None: def test_every_location_is_a_place_and_no_country_is_stated() -> None:
first, _remote, berlin = _rows() first, _remote, berlin = _rows()
assert [p["text"] for p in first["places"]] == [ assert [p["text"] for p in first["places"]] == [
"Amsterdam, Noord-Holland, Netherlands", "Sofia, Bulgaria"] "Amsterdam, Noord-Holland, Netherlands", "Sofia, Bulgaria"]
assert first["location"] == "Amsterdam, Noord-Holland, Netherlands; Sofia, Bulgaria" assert first["location"] == "Amsterdam, Noord-Holland, Netherlands; Sofia, Bulgaria"
assert first["country"] is None # NL and BG assert "country" not in first # prep derives it from the places
assert berlin["places"] == [{"text": "Berlin, Germany", "remote": None}] assert berlin["places"] == [{"text": "Berlin, Germany", "remote": None}]
assert berlin["country"] == "DE"
def test_remote_job_is_not_a_place() -> None: def test_remote_job_is_not_a_place() -> None:
@@ -48,28 +44,16 @@ def test_remote_job_is_not_a_place() -> None:
assert remote["location"] == "Remote" assert remote["location"] == "Remote"
offer = {"id": 1, "title": "T", "careers_url": "https://a.example/o/t", "location": "Remote job", offer = {"id": 1, "title": "T", "careers_url": "https://a.example/o/t", "location": "Remote job",
"remote": False} "remote": False}
assert recruitee._places(offer) == ([], set()) assert recruitee._places(offer) == []
def test_an_offer_without_a_locations_list_falls_back_to_its_location() -> None: def test_an_offer_without_a_locations_list_falls_back_to_its_location() -> None:
offer = {"location": "Lisbon, Portugal", "country_code": "pt"} offer = {"location": "Lisbon, Portugal", "country_code": "pt"}
assert recruitee._places(offer) == ([{"text": "Lisbon, Portugal", "remote": None}], {"PT"}) assert recruitee._places(offer) == [{"text": "Lisbon, Portugal", "remote": None}]
def test_the_stated_level_and_employment_are_mapped() -> None: def test_the_stated_level_and_employment_are_the_hosts_codes() -> None:
rows = _rows() rows = _rows()
assert [r["seniority"] for r in rows] == [None, "junior", "intern"] assert [r["seniority"] for r in rows] == ["experienced", "entry_level", "student_school"]
assert [r["employment"] for r in rows] == ["full_time", "part_time", "internship"] assert [r["employment"] for r in rows] == [
assert recruitee._employment("fulltime_fixed_term") == "temporary" "fulltime_permanent", "parttime_permanent", "internship"]
assert recruitee._employment("freelance") == "contract"
def test_the_table_speaks_the_apps_vocabulary_and_a_new_word_is_logged(
caplog: pytest.LogCaptureFixture) -> None:
assert {v for v in recruitee._SENIORITY.values() if v} <= set(SENIORITIES)
with caplog.at_level(logging.DEBUG, logger=recruitee.__name__):
assert recruitee._seniority("senior_level") is None
assert recruitee._employment("odd_job") is None
assert [r.getMessage() for r in caplog.records] == [
"recruitee: unknown experience_code 'senior_level'",
"recruitee: unknown employment_type_code 'odd_job'"]
+10 -14
View File
@@ -41,21 +41,18 @@ def test_rows_merge_one_entry_per_place_into_one_role() -> None:
assert first["description"] == "" and first["salary_text"] == "" and first["posted"] is None assert first["description"] == "" and first["salary_text"] == "" and first["posted"] is None
def test_remote_is_true_only_when_every_place_is_a_remote_one() -> None: def test_a_remote_place_is_flagged_and_the_role_states_no_remote() -> None:
by_id = {r["source_id"][:8]: r for r in rippling.parse(BOARD, "rippling")} by_id = {r["source_id"][:8]: r for r in rippling.parse(BOARD, "rippling")}
assert by_id["46b4af52"]["remote"] is True and by_id["19ae5b34"]["remote"] is True assert [p["remote"] for p in by_id["46b4af52"]["places"]] == [True]
assert by_id["75ad50c6"]["remote"] is None # an office label says nothing either way assert [p["remote"] for p in by_id["75ad50c6"]["places"]] == [None] # an office label
mixed = json.dumps([ assert all("remote" not in r for r in by_id.values()) # prep derives it from the places
{"uuid": "abcdefgh-1", "name": "A", "workLocation": {"label": "Remote (Germany)"}},
{"uuid": "abcdefgh-1", "name": "A", "workLocation": {"label": "Berlin"}}]).encode()
assert rippling.parse(mixed, "x")[0]["remote"] is None
def test_prisma_board_reads_two_roles() -> None: def test_prisma_board_reads_two_roles() -> None:
rows = rippling.parse(PRISMA, "prisma-careers") rows = rippling.parse(PRISMA, "prisma-careers")
assert [(r["title"], r["department"], r["location"], r["remote"]) for r in rows] == [ assert [(r["title"], r["department"], r["location"]) for r in rows] == [
("General Applications: Engineering", "Engineering", "Remote (Germany)", True), ("General Applications: Engineering", "Engineering", "Remote (Germany)"),
("General Applications: Product", "Product", "Remote (Germany)", True)] ("General Applications: Product", "Product", "Remote (Germany)")]
def test_an_empty_board_is_no_roles_and_an_error_answer_is_not_a_board() -> None: def test_an_empty_board_is_no_roles_and_an_error_answer_is_not_a_board() -> None:
@@ -92,7 +89,7 @@ def test_detail_reads_description_places_date_and_a_single_yearly_range() -> Non
assert "<" not in found["description"] assert "<" not in found["description"]
assert found["location"] == "San Francisco, CA; Seattle, WA; New York, NY" assert found["location"] == "San Francisco, CA; Seattle, WA; New York, NY"
assert [p["text"] for p in found["places"]] == ["San Francisco, CA", "Seattle, WA", "New York, NY"] assert [p["text"] for p in found["places"]] == ["San Francisco, CA", "Seattle, WA", "New York, NY"]
assert found["employment"] == "full_time" # employmentType.label SALARIED_FT assert found["employment"] == "SALARIED_FT" # employmentType.label
assert found["posted"] is not None and found["posted"].isoformat() == \ assert found["posted"] is not None and found["posted"].isoformat() == \
"2025-04-07T12:29:19.348000-07:00" "2025-04-07T12:29:19.348000-07:00"
assert (found["salary_min"], found["salary_max"], found["currency"]) == (216000, 378000, "USD") assert (found["salary_min"], found["salary_max"], found["currency"]) == (216000, 378000, "USD")
@@ -203,13 +200,12 @@ def test_discovery_finds_the_board_slug() -> None:
("rippling", "prisma-careers"), ("rippling", "Acme"), ("rippling", "beta")] ("rippling", "prisma-careers"), ("rippling", "Acme"), ("rippling", "beta")]
def test_a_role_at_several_places_keeps_each_once_and_is_remote_only_if_all_are() -> None: def test_a_role_at_several_places_keeps_each_once() -> None:
rows = {r["source_id"]: r for r in rippling.parse(BOARD, "rippling")} rows = {r["source_id"]: r for r in rippling.parse(BOARD, "rippling")}
director = rows[DIRECTOR] director = rows[DIRECTOR]
assert [p["text"] for p in director["places"]] == [ assert [p["text"] for p in director["places"]] == [
"San Francisco, CA", "Seattle, WA", "New York, NY"] "San Francisco, CA", "Seattle, WA", "New York, NY"]
assert director["location"] == "San Francisco, CA; Seattle, WA; New York, NY" assert director["location"] == "San Francisco, CA; Seattle, WA; New York, NY"
assert director["remote"] is None
remote = next(r for r in rows.values() if r["places"] == [ remote = next(r for r in rows.values() if r["places"] == [
{"text": "Remote (United States)", "remote": True}]) {"text": "Remote (United States)", "remote": True}])
assert remote["remote"] is True assert remote["places"][0]["remote"] is True
+5 -23
View File
@@ -4,17 +4,14 @@ No network: the shapes are those of Bosch's board, read on 2026-09-30."""
from __future__ import annotations from __future__ import annotations
import json import json
import logging
import sys import sys
from pathlib import Path from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path: if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT)) sys.path.insert(0, str(ROOT))
from app.models import SENIORITIES # noqa: E402
from plugins.readers import Ask, smartrecruiters # noqa: E402 from plugins.readers import Ask, smartrecruiters # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "ats" FIXTURES = ROOT / "tests" / "fixtures" / "ats"
@@ -54,38 +51,23 @@ def test_page_reads_by_offset_and_takes_the_ask() -> None:
def test_the_place_is_one_clean_line_with_its_remote_flag_and_country() -> None: def test_the_place_is_one_clean_line_with_its_remote_flag_and_country() -> None:
[row] = _rows(_posting()) [row] = _rows(_posting())
assert row["places"] == [{"text": "Hatvan, Hungary", "remote": False}] # ", ," gone assert row["places"] == [{"text": "Hatvan, Hungary", "remote": False}] # ", ," gone
assert row["location"] == "Hatvan, Hungary" and row["country"] == "HU" assert row["location"] == "Hatvan, Hungary" and row["country"] == "hu"
[remote] = _rows(_posting(location={"remote": True, "fullLocation": "Remote", "country": ""})) [remote] = _rows(_posting(location={"remote": True, "fullLocation": "Remote", "country": ""}))
assert remote["places"] == [{"text": "Remote", "remote": True}] and remote["country"] is None assert remote["places"] == [{"text": "Remote", "remote": True}] and remote["country"] is None
[none] = _rows(_posting(location={})) [none] = _rows(_posting(location={}))
assert none["places"] == [] and none["location"] == "" assert none["places"] == [] and none["location"] == ""
def test_the_stated_level_and_employment_are_mapped() -> None: def test_the_stated_level_and_employment_are_the_hosts_words() -> None:
[row] = _rows(_posting(experienceLevel={"id": "internship", "label": "Internship"}, [row] = _rows(_posting(experienceLevel={"id": "internship", "label": "Internship"},
typeOfEmployment={"id": "intern", "label": "Intern"})) typeOfEmployment={"id": "intern", "label": "Intern"}))
assert (row["seniority"], row["employment"]) == ("intern", "internship") assert (row["seniority"], row["employment"]) == ("internship", "intern")
levels = {"entry_level": "junior", "director": "director", "executive": "exec", [row] = _rows(_posting(experienceLevel={"id": "mid_senior_level"}))
"associate": None, "mid_senior_level": None, "not_applicable": None} assert row["seniority"] == "mid_senior_level"
for word, want in levels.items():
[row] = _rows(_posting(experienceLevel={"id": word}))
assert row["seniority"] == want, word
[row] = _rows(_posting(typeOfEmployment={"id": "permanent"}))
assert row["employment"] is None
[row] = _rows(_posting()) [row] = _rows(_posting())
assert row["seniority"] is None and row["employment"] is None assert row["seniority"] is None and row["employment"] is None
def test_the_table_speaks_the_apps_vocabulary_and_a_new_word_is_logged(
caplog: pytest.LogCaptureFixture) -> None:
assert {v for v in smartrecruiters._SENIORITY.values() if v} <= set(SENIORITIES)
with caplog.at_level(logging.DEBUG, logger=smartrecruiters.__name__):
[row] = _rows(_posting(experienceLevel={"id": "guru"}))
assert row["seniority"] is None
assert [r.getMessage() for r in caplog.records] == [
"smartrecruiters: unknown experienceLevel 'guru'"]
def test_the_saved_page_still_reads() -> None: def test_the_saved_page_still_reads() -> None:
data = json.loads((FIXTURES / "smartrecruiters.json").read_bytes()) data = json.loads((FIXTURES / "smartrecruiters.json").read_bytes())
assert [r["location"] for r in smartrecruiters.rows(data, "Acme")] == ["Berlin, Germany", assert [r["location"] for r in smartrecruiters.rows(data, "Acme")] == ["Berlin, Germany",
+3 -13
View File
@@ -315,7 +315,7 @@ def _detail(name: str, url: str = "https://careers.vestas.com/job/x/1431772533/"
return successfactors.detail(get, "careers.vestas.com", {"url": url}) # type: ignore[arg-type] return successfactors.detail(get, "careers.vestas.com", {"url": url}) # type: ignore[arg-type]
def test_detail_reads_the_description_the_date_and_the_country_code_of_an_address() -> None: def test_detail_reads_the_description_the_date_and_the_places_of_an_address() -> None:
got = _detail("successfactors-job.html") got = _detail("successfactors-job.html")
assert got["description"].startswith("Senior Management | Full-Time | Commercial Are you") assert got["description"].startswith("Senior Management | Full-Time | Commercial Are you")
assert "<" not in got["description"] assert "<" not in got["description"]
@@ -324,7 +324,7 @@ def test_detail_reads_the_description_the_date_and_the_country_code_of_an_addres
# The locality and the country's name; the region is cut to "Seou" by the site. # The locality and the country's name; the region is cut to "Seou" by the site.
assert got["location"] == "Seoul, South Korea" assert got["location"] == "Seoul, South Korea"
assert got["places"] == [{"text": "Seoul, South Korea", "remote": None}] assert got["places"] == [{"text": "Seoul, South Korea", "remote": None}]
assert got["country"] == "KR" assert "country" not in got # prep derives it from the places
def test_detail_keeps_every_address_of_a_role_at_several_places() -> None: def test_detail_keeps_every_address_of_a_role_at_several_places() -> None:
@@ -333,15 +333,6 @@ def test_detail_keeps_every_address_of_a_role_at_several_places() -> None:
assert [p["text"] for p in got["places"]] == [ assert [p["text"] for p in got["places"]] == [
"Seoul, South Korea", "Busan, South Korea", "Aarhus, Denmark"] "Seoul, South Korea", "Busan, South Korea", "Aarhus, Denmark"]
assert got["location"] == "Seoul, South Korea; Busan, South Korea; Aarhus, Denmark" assert got["location"] == "Seoul, South Korea; Busan, South Korea; Aarhus, Denmark"
assert "country" not in got # KR and DK: no single country for the role
def test_detail_states_the_country_when_every_address_is_in_it() -> None:
text = _read("successfactors-places-detail.html").replace(
'content="Aarhus, DK, 8200"', 'content="Daegu, KR, 41200"')
got = successfactors.detail(lambda url, **kw: text.encode(), "careers.vestas.com",
{"url": "https://careers.vestas.com/job/x/1/"})
assert got["country"] == "KR"
def test_the_listing_place_is_the_roles_only_place_until_its_page_is_read() -> None: def test_the_listing_place_is_the_roles_only_place_until_its_page_is_read() -> None:
@@ -351,11 +342,10 @@ def test_the_listing_place_is_the_roles_only_place_until_its_page_is_read() -> N
for r in rows) for r in rows)
def test_detail_reads_the_country_from_a_street_address() -> None: def test_detail_reads_the_place_from_a_street_address() -> None:
"""Systematic and most other sites give one `streetAddress`, "City, CC, zip".""" """Systematic and most other sites give one `streetAddress`, "City, CC, zip"."""
got = _detail("successfactors-job-street.html") got = _detail("successfactors-job-street.html")
assert got["location"] == "Bern, Switzerland" assert got["location"] == "Bern, Switzerland"
assert got["country"] == "CH"
assert got["posted"] == datetime(2026, 9, 28, 2, tzinfo=UTC) assert got["posted"] == datetime(2026, 9, 28, 2, tzinfo=UTC)
assert got["description"].startswith("Senior Solution Engineer Defence") assert got["description"].startswith("Senior Solution Engineer Defence")
+3 -11
View File
@@ -5,11 +5,9 @@ No network: the fixture has the shape of Hugging Face's board, read on
from __future__ import annotations from __future__ import annotations
import json import json
import logging
import sys import sys
from pathlib import Path from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path: if str(ROOT) not in sys.path:
@@ -49,21 +47,15 @@ def test_every_location_of_a_role_is_a_place_once() -> None:
assert [p["text"] for p in first["places"]] == ["Berlin, Germany", "Munich, Bavaria, Germany", assert [p["text"] for p in first["places"]] == ["Berlin, Germany", "Munich, Bavaria, Germany",
"Paris, France"] "Paris, France"]
assert first["location"] == "Berlin, Germany; Munich, Bavaria, Germany; Paris, France" assert first["location"] == "Berlin, Germany; Munich, Bavaria, Germany; Paris, France"
assert first["country"] is None # DE and FR assert "country" not in first # prep derives it from the places
assert [p["remote"] for p in first["places"]] == [False] * 3 assert [p["remote"] for p in first["places"]] == [False] * 3
assert remote["places"] == [{"text": "France", "remote": True}] assert remote["places"] == [{"text": "France", "remote": True}]
assert remote["country"] == "FR"
# A list-less answer (the older shape) still gives its one place. # A list-less answer (the older shape) still gives its one place.
assert oslo["places"] == [{"text": "Oslo, Norway", "remote": False}] assert oslo["places"] == [{"text": "Oslo, Norway", "remote": False}]
assert oslo["country"] == "NO"
def test_the_stated_hours_are_mapped_and_an_unknown_type_is_logged( def test_the_stated_hours_are_the_hosts_word() -> None:
caplog: pytest.LogCaptureFixture) -> None: assert [r["employment"] for r in _rows()] == ["full", "part", "volunteer"]
with caplog.at_level(logging.DEBUG, logger=workable.__name__):
rows = _rows()
assert [r["employment"] for r in rows] == ["full_time", "part_time", None]
assert [r.getMessage() for r in caplog.records] == ["workable: unknown type 'volunteer'"]
def test_the_shape_of_a_real_list_answer_is_read() -> None: def test_the_shape_of_a_real_list_answer_is_read() -> None:
+10 -11
View File
@@ -54,8 +54,8 @@ def test_rows_read_the_listing_of_a_tenant_that_sends_remote_type() -> None:
"Associate-Solutions-Architect_R35358") "Associate-Solutions-Architect_R35358")
assert first["posted"] == TODAY assert first["posted"] == TODAY
assert first["description"] == "" and first["department"] == "" and first["salary_text"] == "" assert first["description"] == "" and first["department"] == "" and first["salary_text"] == ""
# "Fully Flexible" is Zendesk's word for remote. # The host's own words, "Fully Flexible" among them; prep maps them.
assert [r["remote"] for r in rows] == ["remote", "onsite", "hybrid", "remote", "hybrid"] assert [r["remote"] for r in rows] == ["Fully Flexible", "In Office", "Hybrid", "Fully Flexible", "Hybrid"]
def test_rows_of_a_tenant_without_remote_type_leave_remote_unknown() -> None: def test_rows_of_a_tenant_without_remote_type_leave_remote_unknown() -> None:
@@ -80,7 +80,7 @@ def test_rows_of_a_site_called_jobs_state_the_requisition_id_and_no_date_past_30
assert rows[1]["places"] == [{"text": "Remote US TX", "remote": True}] assert rows[1]["places"] == [{"text": "Remote US TX", "remote": True}]
assert rows[2]["url"].startswith("https://redhat.wd5.myworkdayjobs.com/jobs/job/") 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 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"] assert [r["remote"] for r in rows] == ["Onsite", "Remote", "Remote", "Hybrid"]
@pytest.mark.parametrize(("text", "expected"), [ @pytest.mark.parametrize(("text", "expected"), [
@@ -275,13 +275,12 @@ def test_detail_reads_the_description_date_remote_and_place_of_the_role() -> Non
SLUG, row) SLUG, row)
assert asked == [f"https://{HOST}/wday/cxs/zendesk/zendesk" assert asked == [f"https://{HOST}/wday/cxs/zendesk/zendesk"
"/job/Remote-Mexico-City-Mexico/Associate-Solutions-Architect_R35358"] "/job/Remote-Mexico-City-Mexico/Associate-Solutions-Architect_R35358"]
assert set(got) == {"description", "location", "places", "posted", "remote", "country", assert set(got) == {"description", "location", "places", "posted", "remote", "employment"}
"employment"}
assert got["posted"] == datetime(2026, 9, 29, tzinfo=UTC) assert got["posted"] == datetime(2026, 9, 29, tzinfo=UTC)
assert got["remote"] == "remote" assert got["remote"] == "Fully Flexible"
assert got["location"] == "Remote, Mexico City, Mexico" assert got["location"] == "Remote, Mexico City, Mexico"
assert got["places"] == [{"text": "Remote, Mexico City, Mexico", "remote": True}] assert got["places"] == [{"text": "Remote, Mexico City, Mexico", "remote": True}]
assert (got["country"], got["employment"]) == ("MX", "full_time") assert got["employment"] == "Full time" and "country" not in got
assert got["description"].startswith("Job Description") or len(got["description"]) > 200 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"] and "&nbsp;" not in got["description"]
assert " " not in got["description"] assert " " not in got["description"]
@@ -296,7 +295,7 @@ def test_detail_names_every_location_of_a_role_listed_as_several() -> None:
"/job/Remote-Italy/Telco-Cloud-Consultant_R-059566-2"] "/job/Remote-Italy/Telco-Cloud-Consultant_R-059566-2"]
assert got["location"] == "Remote Italy; Remote Spain" assert got["location"] == "Remote Italy; Remote Spain"
assert [p["text"] for p in got["places"]] == ["Remote Italy", "Remote Spain"] assert [p["text"] for p in got["places"]] == ["Remote Italy", "Remote Spain"]
assert "country" not in got # the code belongs to the main location alone assert "country" not in got
def _detail(**info: Any) -> bytes: def _detail(**info: Any) -> bytes:
@@ -337,9 +336,9 @@ def test_a_country_dash_city_place_is_turned_round() -> None:
assert workday._place("12 Locations", None) is None assert workday._place("12 Locations", None) is None
def test_detail_takes_no_word_for_remote_it_does_not_know() -> None: def test_detail_hands_on_a_word_for_remote_it_does_not_know() -> None:
row = workday.rows(_load("workday.json"), SLUG)[0] row = workday.rows(_load("workday.json"), SLUG)[0]
assert "remote" not in workday.detail(_get_of(_detail(remoteType="No"), []), SLUG, row) assert workday.detail(_get_of(_detail(remoteType="No"), []), SLUG, row)["remote"] == "No"
def test_detail_refuses_a_row_that_is_not_a_role_of_the_board() -> None: def test_detail_refuses_a_row_that_is_not_a_role_of_the_board() -> None:
@@ -383,7 +382,7 @@ def test_detail_is_read_through_the_getter_ats_binds(
monkeypatch.setattr(ats, "_get", fake_get) monkeypatch.setattr(ats, "_get", fake_get)
row = workday.rows(_load("workday.json"), SLUG)[0] row = workday.rows(_load("workday.json"), SLUG)[0]
got = workday.detail(ats._getter(object(), "workday", SLUG), SLUG, row) # type: ignore[arg-type] got = workday.detail(ats._getter(object(), "workday", SLUG), SLUG, row) # type: ignore[arg-type]
assert got["remote"] == "remote" assert got["remote"] == "Fully Flexible"
assert seen[0][:2] == ("workday", SLUG) assert seen[0][:2] == ("workday", SLUG)
+12
View File
@@ -0,0 +1,12 @@
"""Oracle's word tables for prep: the host's codes, and what they mean."""
from __future__ import annotations
import importlib
oracle = importlib.import_module("app.prep.hosts.oracle")
def test_workplace_type_codes_read() -> None:
assert oracle.REMOTE == {"ora_remote": "remote", "ora_hybrid": "hybrid",
"ora_on_site": "onsite"}
+22
View File
@@ -0,0 +1,22 @@
"""Personio's word tables for prep: the feed's own words, and what they mean."""
from __future__ import annotations
import importlib
personio = importlib.import_module("app.prep.hosts.personio")
def test_seniority_words_read() -> None:
seniority = personio.SENIORITY
assert [seniority[w] for w in ("entry-level", "executive", "student")] == [
"junior", "exec", "intern"]
assert seniority["experienced"] == "" # known, names no level
assert "wizard" not in seniority
def test_employment_words_read_from_the_contract_or_the_schedule() -> None:
employment = personio.EMPLOYMENT
assert employment["working_student"] == "internship" and employment["freelance"] == "contract"
assert employment["permanent"] == ""
assert employment["full-time"] == "full_time" and employment["part-time"] == "part_time"
+12
View File
@@ -0,0 +1,12 @@
"""Phenom's word table for prep: the words a page's `checkRemote` says."""
from __future__ import annotations
import importlib
phenom = importlib.import_module("app.prep.hosts.phenom")
def test_check_remote_words_read() -> None:
assert phenom.REMOTE["on-site"] == "onsite" # King's pages
assert phenom.REMOTE["remote"] == "remote" and phenom.REMOTE["hybrid"] == "hybrid"
+24
View File
@@ -0,0 +1,24 @@
"""Pinpoint's word tables for prep: `workplace_type` and `employment_type`."""
from __future__ import annotations
import importlib
pinpoint = importlib.import_module("app.prep.hosts.pinpoint")
def _match(code: str) -> str | None:
"""The first entry of `MATCH` found in the lowercased code."""
code = code.strip().lower()
return next((value for fragment, value in pinpoint.MATCH if fragment in code), None)
def test_workplace_types_read() -> None:
assert pinpoint.REMOTE == {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid",
"remote": "remote"}
def test_employment_types_read_by_their_fragments() -> None:
assert [_match(w) for w in ("permanent_full_time", "fixed_term_full_time",
"permanent_part_time", "internship", "something_new")] == [
"full_time", "temporary", "part_time", "internship", None]
+27
View File
@@ -0,0 +1,27 @@
"""Recruitee's word tables for prep: the host's codes, and what they mean."""
from __future__ import annotations
import importlib
recruitee = importlib.import_module("app.prep.hosts.recruitee")
def _match(word: str) -> str | None:
"""The first entry of `MATCH` found among the words of a code."""
words = set(word.strip().lower().replace("-", "_").split("_"))
return next((value for fragment, value in recruitee.MATCH if fragment in words), None)
def test_experience_codes_read() -> None:
seniority = recruitee.SENIORITY
assert [seniority[w] for w in ("student_school", "entry_level", "mid_level")] == [
"intern", "junior", "mid"]
assert seniority["experienced"] == ""
assert "senior_level" not in seniority
def test_employment_type_codes_read_by_their_words() -> None:
assert [_match(w) for w in ("fulltime_permanent", "parttime_permanent", "internship",
"fulltime_fixed_term", "freelance", "odd_job")] == [
"full_time", "part_time", "internship", "temporary", "contract", None]
+19
View File
@@ -0,0 +1,19 @@
"""Rippling's word table for prep: the words of `employmentType.label`."""
from __future__ import annotations
import importlib
rippling = importlib.import_module("app.prep.hosts.rippling")
def _match(label: str) -> str | None:
"""The first entry of `MATCH` found among the "_"-separated words of a label."""
words = set(label.strip().lower().split("_"))
return next((value for token, value in rippling.MATCH if token in words), None)
def test_employment_labels_read_by_their_words() -> None:
assert [_match(w) for w in ("SALARIED_FT", "HOURLY_PT", "INTERN", "CONTRACTOR",
"SEASONAL", "ODD")] == [
"full_time", "part_time", "internship", "contract", "temporary", None]
+22
View File
@@ -0,0 +1,22 @@
"""SmartRecruiters' word tables for prep: the host's ids, and what they mean."""
from __future__ import annotations
import importlib
smartrecruiters = importlib.import_module("app.prep.hosts.smartrecruiters")
def test_experience_levels_read() -> None:
seniority = smartrecruiters.SENIORITY
assert [seniority[w] for w in ("internship", "entry_level", "director", "executive")] == [
"intern", "junior", "director", "exec"]
# Known, and naming no level.
assert [seniority[w] for w in ("associate", "mid_senior_level", "not_applicable")] == [""] * 3
assert "guru" not in seniority
def test_employment_types_read() -> None:
employment = smartrecruiters.EMPLOYMENT
assert employment["intern"] == "internship" and employment["permanent"] == ""
assert employment["full_time"] == "full_time" and employment["part_time"] == "part_time"
+14
View File
@@ -0,0 +1,14 @@
"""Teamtailor's word table for prep: the feed's `remoteStatus`."""
from __future__ import annotations
import importlib
teamtailor = importlib.import_module("app.prep.hosts.teamtailor")
def test_remote_status_words_read() -> None:
remote = teamtailor.REMOTE
assert [remote[w] for w in ("fully", "hybrid", "onsite")] == ["remote", "hybrid", "onsite"]
# Known, and saying nothing about where the role is worked.
assert remote["none"] == "" and remote["temporary"] == ""
+18
View File
@@ -0,0 +1,18 @@
"""Workable's word tables for prep: the host's own words, lowercased, and what they mean."""
from __future__ import annotations
import importlib
workable = importlib.import_module("app.prep.hosts.workable")
def test_workplace_words_read() -> None:
assert workable.REMOTE == {"remote": "remote", "hybrid": "hybrid", "on_site": "onsite"}
def test_type_words_read() -> None:
assert workable.EMPLOYMENT == {"full": "full_time", "part": "part_time",
"contract": "contract", "temporary": "temporary",
"internship": "internship"}
assert "volunteer" not in workable.EMPLOYMENT # an unknown word is prep's to report
+21
View File
@@ -0,0 +1,21 @@
"""Workday's word tables for prep: the host's own words, lowercased, and what they mean."""
from __future__ import annotations
import importlib
workday = importlib.import_module("app.prep.hosts.workday")
def test_remote_type_words_of_the_tenants_read() -> None:
remote = workday.REMOTE
# Zendesk's "Fully Flexible", Axis' "On-Site", Red Hat's "Onsite".
assert [remote[w] for w in ("remote", "fully flexible", "hybrid", "in office",
"on-site", "onsite")] == [
"remote", "remote", "hybrid", "onsite", "onsite", "onsite"]
assert "no" not in remote # a bare "No" says nothing
def test_time_type_words_read() -> None:
assert workday.EMPLOYMENT == {"full time": "full_time", "part time": "part_time"}
+1 -1
View File
@@ -46,7 +46,7 @@ def test_it_strips_highlights_keeps_the_excerpt_as_teaser_and_drops_predicted_pa
assert "description" not in first assert "description" not in first
assert first["company"] == "Acme GmbH" assert first["company"] == "Acme GmbH"
assert first["places"] == [{"text": "Berlin, Deutschland", "remote": None}] assert first["places"] == [{"text": "Berlin, Deutschland", "remote": None}]
assert first["country"] == "DE" and first["remote"] == "remote" assert first["country"] == "DE" and "remote" not in first
assert (first["salary_min"], first["salary_max"], first["currency"]) == (70000, 90000, "EUR") assert (first["salary_min"], first["salary_max"], first["currency"]) == (70000, 90000, "EUR")
assert (predicted["salary_min"], predicted["currency"]) == (None, None) assert (predicted["salary_min"], predicted["currency"]) == (None, None)
+2 -2
View File
@@ -61,12 +61,12 @@ def test_it_reads_title_company_date_and_the_full_text() -> None:
first, _no_town, remote = platsbanken.rows(decoded, "") first, _no_town, remote = platsbanken.rows(decoded, "")
assert first["title"] == "Postdoctoral Researcher" assert first["title"] == "Postdoctoral Researcher"
assert first["company"] == "European Spallation Source Eric" assert first["company"] == "European Spallation Source Eric"
assert first["country"] == "SE" and first["remote"] is None assert first["country"] == "SE" and first["remote"] == "Arbete på plats"
assert first["url"] == "https://arbetsformedlingen.se/platsbanken/annonser/31457942" assert first["url"] == "https://arbetsformedlingen.se/platsbanken/annonser/31457942"
assert first["posted"].date().isoformat() == "2026-09-09" assert first["posted"].date().isoformat() == "2026-09-09"
assert first["description"].startswith("The European Spallation Source") assert first["description"].startswith("The European Spallation Source")
assert "teaser" not in first assert "teaser" not in first
assert (remote["remote"], remote["company"], remote["posted"]) == ("remote", "", None) assert (remote["remote"], remote["company"], remote["posted"]) == (None, "", None)
def test_it_sends_the_region_the_offset_and_no_region_for_all_of_sweden() -> None: def test_it_sends_the_region_the_offset_and_no_region_for_all_of_sweden() -> None:
+32
View File
@@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import importlib
import logging import logging
import sys import sys
from pathlib import Path from pathlib import Path
@@ -24,6 +25,16 @@ from plugins.readers._shared import ( # noqa: E402
#: The module-level names a reader keeps its employment words in. #: The module-level names a reader keeps its employment words in.
_TABLES = ("_EMPLOYMENT", "_CONTRACT", "_SCHEDULE") _TABLES = ("_EMPLOYMENT", "_CONTRACT", "_SCHEDULE")
#: The hosts whose word tables are prep's, in `app/prep/hosts/<name>.py`.
_PREP_HOSTS = ("oracle", "personio", "phenom", "pinpoint", "recruitee", "rippling",
"smartrecruiters", "teamtailor", "workable", "workday")
def _prep_table(name: str, table_name: str):
"""A word table of `app.prep.hosts.<name>`, or None where it has none."""
module = importlib.import_module(f"app.prep.hosts.{name}")
return getattr(module, table_name, None)
def test_every_employment_table_maps_into_the_shared_vocabulary() -> None: def test_every_employment_table_maps_into_the_shared_vocabulary() -> None:
found = 0 found = 0
@@ -36,9 +47,30 @@ 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] values = table.values() if isinstance(table, dict) else [v for _k, v in table]
# "" is a known word that names no employment ("permanent"). # "" is a known word that names no employment ("permanent").
assert set(values) <= {*EMPLOYMENTS, ""}, (name, table_name) assert set(values) <= {*EMPLOYMENTS, ""}, (name, table_name)
for name in _PREP_HOSTS:
for table_name in ("EMPLOYMENT", "MATCH"):
table = _prep_table(name, table_name)
if table is None:
continue
values = table.values() if isinstance(table, dict) else [v for _k, v in table]
found += 1
assert set(values) <= {*EMPLOYMENTS, ""}, (name, table_name)
assert found >= 15 assert found >= 15
def test_the_prep_tables_of_the_hosts_speak_the_apps_vocabulary() -> None:
from app.models import SENIORITIES
for name in _PREP_HOSTS:
seniority = _prep_table(name, "SENIORITY")
if seniority is not None:
assert set(seniority.values()) <= {*SENIORITIES, ""}, name
remote = _prep_table(name, "REMOTE")
if remote is not None:
assert set(remote.values()) <= {"remote", "hybrid", "onsite", ""}, name
for table in (seniority, remote, _prep_table(name, "EMPLOYMENT")):
assert table is None or all(k == k.lower() for k in table), name
def test_the_vocabulary_is_the_documented_one() -> None: def test_the_vocabulary_is_the_documented_one() -> None:
assert EMPLOYMENTS == ("full_time", "part_time", "contract", "temporary", "internship", assert EMPLOYMENTS == ("full_time", "part_time", "contract", "temporary", "internship",
"freelance") "freelance")