"""Teamtailor: every location of a role, kept as a place. No network: the fixture is the trimmed feed of Kry and Tobii, read on 2026-09-29.""" from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from plugins.readers import Ask, _runner, teamtailor # noqa: E402 FIXTURES = ROOT / "tests" / "fixtures" / "ats" def _rows() -> list[dict]: return teamtailor.parse((FIXTURES / "teamtailor-places.xml").read_bytes(), "kry") def test_the_declaration_says_what_the_feed_gives() -> None: reads = teamtailor.READS assert (reads.listing, reads.page_size, reads.places, reads.text, reads.complete) == \ ("paged", 50, "many", "listing", "end") assert reads.fields.posted == "trusted" and reads.fields.remote == "stated" assert "/jobs.rss is allowed" in reads.robots def test_page_takes_the_ask_and_reads_the_same_url() -> None: asked: list[str] = [] def get(url: str, **_: object) -> bytes: asked.append(url) return (FIXTURES / "teamtailor-places.xml").read_bytes() _items, results, total, cursor = teamtailor.page(get, "kry", None, Ask()) assert asked == ["https://kry.teamtailor.com/jobs.rss?per_page=50&offset=0"] assert len(results) == 4 and total is None and cursor == 4 def test_every_distinct_location_is_a_place_with_the_roles_work_mode() -> None: first, second, third, refused = _rows() assert not _runner.valid(refused) # javascript:, for the runner # "Sverige" (a city that is a country) once, Stockholm's twin once. assert first["places"] == [{"text": "Sverige, Sweden", "remote": False}, # hybrid {"text": "Stockholm, Sweden", "remote": False}] assert first["location"] == "Sverige, Sweden; Stockholm, Sweden" assert second["places"] == [{"text": "Danderyd, Sweden", "remote": True}] # fully assert third["places"] == [] and third["location"] == ""