Every row carries places (Personio additionalOffices, Workable and Recruitee locations[], every SuccessFactors address, Workday's own read), the list teaser of Phenom and Oracle is kept in teaser, and the level, employment and country a host states are mapped. Workday "N Locations" and "Country - City", and Recruitee "Remote job", are no longer places. Phenom takes dateCreated as posted. robots_page and ROBOTS_ANY_CASE go; READS.robots records the decision. Signatures are feed_url(slug, ask) and page(get, slug, cursor, ask), with an empty Ask as the default so the runner of today still calls them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
"""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 logging
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from app.models import SENIORITIES # noqa: E402
|
|
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 first["remote"] is True # one of the places is remote
|
|
assert _rows()[1]["places"] == [{"text": "Munich", "remote": None}]
|
|
assert _rows()[1]["remote"] is None
|
|
|
|
|
|
def test_the_stated_level_and_employment_are_mapped() -> None:
|
|
rows = _rows()
|
|
assert [r["seniority"] for r in rows] == ["junior", "exec", "intern"]
|
|
# permanent + full-time; permanent + full-time; working student wins over part-time
|
|
assert [r["employment"] for r in rows] == ["full_time", "full_time", "internship"]
|
|
|
|
|
|
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'"]
|