"""The Greenhouse host module's places, against a small saved board with `offices`. No network. The pay and the plain row are in `test_ats.py`.""" 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, greenhouse # noqa: E402 BOARD = (ROOT / "tests" / "fixtures" / "ats" / "greenhouse-places.json").read_bytes() def test_a_placeholder_location_is_replaced_by_the_offices() -> None: hybrid = greenhouse.parse(BOARD, "acme")[0] assert hybrid["places"] == [ {"text": "Austin, TX, United States", "remote": None}, {"text": "New York, New York, United States", "remote": None}] assert hybrid["location"] == "Austin, TX, United States; New York, New York, United States" def test_a_name_the_offices_do_not_contain_is_one_more_place() -> None: remote = greenhouse.parse(BOARD, "acme")[1] assert [p["text"] for p in remote["places"]] == ["Remote India", "Bangalore, India"] assert remote["places"][0]["remote"] is True def test_a_name_an_office_repeats_is_one_place() -> None: lisbon = greenhouse.parse(BOARD, "acme")[2] assert lisbon["places"] == [{"text": "Lisbon, Portugal", "remote": None}] def test_without_offices_the_name_is_the_place() -> None: body = b'{"jobs": [{"id": 1, "title": "T", "absolute_url": "https://gh.example/1", ' \ b'"location": {"name": "Hybrid"}}, {"id": 2, "title": "U", ' \ b'"absolute_url": "https://gh.example/2", "location": {"name": ""}}]}' hybrid, nothing = greenhouse.parse(body, "acme") assert hybrid["places"] == [{"text": "Hybrid", "remote": None}] assert nothing["places"] == [] and nothing["location"] == "" def test_it_declares_a_whole_listing_of_trusted_dates_and_no_robots_check() -> None: reads = greenhouse.READS assert (reads.listing, reads.text, reads.places) == ("whole", "listing", "many") assert reads.fields.posted == "trusted" and reads.fields.pay == "figures" assert reads.robots == "api: no robots.txt check needed (public board API), 2026-09-30" assert greenhouse.feed_url("acme", Ask()).endswith("/boards/acme/jobs?content=true&pay_transparency=true") assert greenhouse.fallback_url("acme").endswith("/boards/acme/jobs")