"""Personio: every office of a role, the level and the employment it states. No network: the fixtures are saved feeds.""" 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, personio # noqa: E402 FIXTURES = ROOT / "tests" / "fixtures" / "ats" def _rows() -> list[dict]: return personio.parse((FIXTURES / "personio-places.xml").read_bytes(), "acme") def test_the_declaration_says_what_the_feed_gives() -> None: reads = personio.READS assert (reads.listing, reads.places, reads.text) == ("whole", "many", "listing") assert reads.fields.posted == "trusted" and reads.fields.seniority == "stated" assert reads.robots.startswith("api: no robots.txt check needed") assert not hasattr(personio, "robots_page") assert personio.feed_url("acme", Ask()) == "https://acme.jobs.personio.de/xml" def test_additional_offices_are_places_of_the_role_each_once() -> None: first = _rows()[0] assert [p["text"] for p in first["places"]] == ["Remote - Germany", "Berlin", "Hamburg"] assert [p["remote"] for p in first["places"]] == [True, None, None] assert first["location"] == "Remote - Germany; Berlin; Hamburg" assert "remote" not in first # the feed states none assert _rows()[1]["places"] == [{"text": "Munich", "remote": None}] def test_the_stated_level_and_employment_are_the_hosts_words() -> None: rows = _rows() assert [r["seniority"] for r in rows] == ["entry-level", "executive", "student"] # 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", "working_student"]