Files
jobboard/tests/test_ats_greenhouse.py
WolfandClaude Fable 5.1 2349fc424b Require READS, search params and a dated robots record; record robots.txt per requested path
Every reader declares, so undeclared(), the scope() fallback, robots_page and
ROBOTS_ANY_CASE go. A search provider needs PARAMS and clean_params, a row may
carry company, places gains none. Each robots record names the paths the
reader requests, from robots.txt read again on 2026-09-30. Platsbanken states
remote, HR Manager states no place.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-30 15:51:13 +02:00

53 lines
2.3 KiB
Python

"""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_its_robots_record() -> 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.startswith("read: ") and "(checked 2026-09-30)" in reads.robots
assert greenhouse.feed_url("acme", Ask()).endswith("/boards/acme/jobs?content=true&pay_transparency=true")
assert greenhouse.fallback_url("acme").endswith("/boards/acme/jobs")