Rename plugins/atshosts to plugins/readers
Every import, test and live doc follows the new path; behaviour is unchanged. tests/test_atshosts.py becomes tests/test_readers.py. plan-readers.md and review-ingest.md keep the old name, since they describe the state before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
af337ef558
commit
73dec9028e
48 files changed
+104
-104
No files matched your search
+1
-1
@@ -19,7 +19,7 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from plugins import ats # noqa: E402
|
||||
from plugins.atshosts import smartrecruiters # noqa: E402
|
||||
from plugins.readers import smartrecruiters # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import bamboohr # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import bamboohr # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
@@ -161,7 +161,7 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
assert allow("configit.bamboohr.com") and allow("CONFIGIT.bamboohr.com")
|
||||
assert not allow("bamboohr.com") and not allow("other.bamboohr.com")
|
||||
assert not allow("configit.bamboohr.com.evil.example") and not allow("localhost")
|
||||
assert atshosts.HOSTS["bamboohr"] is bamboohr and ats.HOSTS["bamboohr"] == "BambooHR"
|
||||
assert readers.HOSTS["bamboohr"] is bamboohr and ats.HOSTS["bamboohr"] == "BambooHR"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", [
|
||||
@@ -182,4 +182,4 @@ def test_discovery_finds_the_subdomain_and_not_bamboohrs_own_hosts() -> None:
|
||||
'<a href="https://www.bamboohr.com/">x</a><a href="https://app.bamboohr.com/x">y</a>'
|
||||
'<a href="https://resources.bamboohr.com/y">z</a>')
|
||||
assert [(h, s) for h, s, _ in discover.boards_in(page)] == [("bamboohr", "configit")]
|
||||
assert "bamboohr" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}
|
||||
assert "bamboohr" not in {h for h, _ in discover._UNREADABLE if h not in readers.HOSTS}
|
||||
@@ -16,8 +16,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import deel # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import deel # noqa: E402
|
||||
|
||||
PAGE = (ROOT / "tests" / "fixtures" / "ats" / "deel.html").read_bytes()
|
||||
URL = "https://jobs.deel.com/klarna"
|
||||
@@ -126,7 +126,7 @@ def test_a_page_that_cannot_be_read_fails_the_board(web: dict[str, Any]) -> None
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
|
||||
def test_the_module_is_registered_as_a_feed_host() -> None:
|
||||
assert atshosts.HOSTS["deel"] is deel and ats.HOSTS["deel"] == "Deel"
|
||||
assert readers.HOSTS["deel"] is deel and ats.HOSTS["deel"] == "Deel"
|
||||
assert deel.NAME == "deel" and deel.KEEP_CASE
|
||||
assert not hasattr(deel, "page") and not hasattr(deel, "detail")
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import eightfold # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import eightfold # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
SLUG = "jobs.ericsson.com/ericsson.com"
|
||||
@@ -169,7 +169,7 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
assert allow("jobs.ericsson.com") and allow("JOBS.ERICSSON.COM")
|
||||
assert not allow("ericsson.com") and not allow("evil.example")
|
||||
assert not allow("jobs.ericsson.com.evil.example") and not allow("localhost")
|
||||
assert atshosts.HOSTS["eightfold"] is eightfold and ats.HOSTS["eightfold"] == "Eightfold"
|
||||
assert readers.HOSTS["eightfold"] is eightfold and ats.HOSTS["eightfold"] == "Eightfold"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", [
|
||||
@@ -192,4 +192,4 @@ def test_discovery_reads_the_host_and_domain_from_a_link_that_has_both() -> None
|
||||
found = [(h, s) for h, s, _ in discover.boards_in(page)]
|
||||
assert ("eightfold", "infineon.eightfold.ai/infineon.com") in found
|
||||
assert ("eightfold", "") in found
|
||||
assert "eightfold" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}
|
||||
assert "eightfold" not in {h for h, _ in discover._UNREADABLE if h not in readers.HOSTS}
|
||||
@@ -17,8 +17,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import gem # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import gem # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
API = "https://jobs.gem.com/api/public/graphql"
|
||||
@@ -154,7 +154,7 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
assert allow("jobs.gem.com") and allow("JOBS.gem.com")
|
||||
assert not allow("gem.com") and not allow("productboard.gem.com")
|
||||
assert not allow("jobs.gem.com.evil.example") and not allow("localhost")
|
||||
assert atshosts.HOSTS["gem"] is gem and ats.HOSTS["gem"] == "Gem"
|
||||
assert readers.HOSTS["gem"] is gem and ats.HOSTS["gem"] == "Gem"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", [
|
||||
@@ -177,4 +177,4 @@ def test_discovery_finds_the_board_keeping_its_case() -> None:
|
||||
'<a href="https://jobs.gem.com/sennder-gmbh/8080046002">y</a>')
|
||||
assert [(h, s) for h, s, _ in discover.boards_in(page)] == [
|
||||
("gem", "Productboard"), ("gem", "sennder-gmbh")]
|
||||
assert "gem" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}
|
||||
assert "gem" not in {h for h, _ in discover._UNREADABLE if h not in readers.HOSTS}
|
||||
@@ -16,8 +16,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import hibob # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import hibob # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
BOARD = (FIXTURES / "hibob.json").read_bytes()
|
||||
@@ -171,7 +171,7 @@ def test_the_robots_txt_that_is_the_apps_own_page_allows(web: dict[str, Any]) ->
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
|
||||
def test_the_module_is_registered_as_a_paged_host() -> None:
|
||||
assert atshosts.HOSTS["hibob"] is hibob and ats.HOSTS["hibob"] == "HiBob"
|
||||
assert readers.HOSTS["hibob"] is hibob and ats.HOSTS["hibob"] == "HiBob"
|
||||
assert hibob.NAME == "hibob" and not getattr(hibob, "KEEP_CASE", False)
|
||||
assert hasattr(hibob, "page") and not hasattr(hibob, "detail")
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import hrmanager # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import hrmanager # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
BOARD = (FIXTURES / "hrmanager.xml").read_bytes()
|
||||
@@ -155,7 +155,7 @@ def test_the_robots_page_is_the_feed_so_that_its_own_hosts_rules_decide(
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
|
||||
def test_the_module_is_registered_as_a_paged_host() -> None:
|
||||
assert atshosts.HOSTS["hrmanager"] is hrmanager and ats.HOSTS["hrmanager"] == "HR Manager"
|
||||
assert readers.HOSTS["hrmanager"] is hrmanager and ats.HOSTS["hrmanager"] == "HR Manager"
|
||||
assert hrmanager.NAME == "hrmanager" and not getattr(hrmanager, "KEEP_CASE", False)
|
||||
assert hasattr(hrmanager, "page") and not hasattr(hrmanager, "detail")
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import jibe # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import jibe # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
SITE = "jobs.booking.com"
|
||||
@@ -152,7 +152,7 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
assert allow("jobs.booking.com") and allow("JOBS.BOOKING.COM")
|
||||
assert not allow("booking.com") and not allow("evil.example")
|
||||
assert not allow("jobs.booking.com.evil.example") and not allow("localhost")
|
||||
assert atshosts.HOSTS["jibe"] is jibe and ats.HOSTS["jibe"] == "Jibe"
|
||||
assert readers.HOSTS["jibe"] is jibe and ats.HOSTS["jibe"] == "Jibe"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", [
|
||||
|
||||
@@ -16,8 +16,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import jobylon # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import jobylon # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
BOARD = (FIXTURES / "jobylon.html").read_bytes()
|
||||
@@ -158,7 +158,7 @@ def test_an_empty_board_is_complete(web: dict[str, Any]) -> None:
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
|
||||
def test_the_module_is_registered_as_a_feed_host_with_detail() -> None:
|
||||
assert atshosts.HOSTS["jobylon"] is jobylon and ats.HOSTS["jobylon"] == "Jobylon"
|
||||
assert readers.HOSTS["jobylon"] is jobylon and ats.HOSTS["jobylon"] == "Jobylon"
|
||||
assert jobylon.NAME == "jobylon" and not getattr(jobylon, "KEEP_CASE", False)
|
||||
assert hasattr(jobylon, "detail") and not hasattr(jobylon, "page")
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats # noqa: E402
|
||||
from plugins.atshosts import oracle # noqa: E402
|
||||
from plugins.atshosts._shared import is_web_url # noqa: E402
|
||||
from plugins.readers import oracle # noqa: E402
|
||||
from plugins.readers._shared import is_web_url # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
HOST = "fa-evmr-saasfaprod1.fa.ocs.oraclecloud.com"
|
||||
|
||||
@@ -19,8 +19,8 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats # noqa: E402
|
||||
from plugins.atshosts import phenom # noqa: E402
|
||||
from plugins.atshosts._shared import is_web_url # noqa: E402
|
||||
from plugins.readers import phenom # noqa: E402
|
||||
from plugins.readers._shared import is_web_url # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
SLUG = "careers.king.com/us/en"
|
||||
|
||||
@@ -14,8 +14,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import pinpoint # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import pinpoint # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
@@ -122,7 +122,7 @@ def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
assert allow("xeneta.pinpointhq.com") and allow("XENETA.pinpointhq.com")
|
||||
assert not allow("pinpointhq.com") and not allow("other.pinpointhq.com")
|
||||
assert not allow("xeneta.pinpointhq.com.evil.example") and not allow("localhost")
|
||||
assert atshosts.HOSTS["pinpoint"] is pinpoint and ats.HOSTS["pinpoint"] == "Pinpoint"
|
||||
assert readers.HOSTS["pinpoint"] is pinpoint and ats.HOSTS["pinpoint"] == "Pinpoint"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", [
|
||||
@@ -146,7 +146,7 @@ def test_discovery_finds_the_subdomain() -> None:
|
||||
'<script src="https://www.pinpointhq.com/embed.js"></script>')
|
||||
assert [(h, s) for h, s, _ in discover.boards_in(page)] == [("pinpoint", "xeneta")]
|
||||
assert discover.boards_in("https://pinpointhq.com/") == []
|
||||
assert "pinpoint" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}
|
||||
assert "pinpoint" not in {h for h, _ in discover._UNREADABLE if h not in readers.HOSTS}
|
||||
|
||||
|
||||
def test_a_pinpoint_board_is_not_probed() -> None:
|
||||
|
||||
@@ -17,8 +17,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import rippling # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import rippling # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
BOARD = (FIXTURES / "rippling.json").read_bytes()
|
||||
@@ -168,7 +168,7 @@ def test_robots_are_read_from_the_site_and_disallow_only_internal(
|
||||
# ------------------------------------------------------- slugs and hosts
|
||||
|
||||
def test_the_module_is_registered_as_a_feed_host_with_detail() -> None:
|
||||
assert atshosts.HOSTS["rippling"] is rippling and ats.HOSTS["rippling"] == "Rippling"
|
||||
assert readers.HOSTS["rippling"] is rippling and ats.HOSTS["rippling"] == "Rippling"
|
||||
assert rippling.NAME == "rippling" and rippling.KEEP_CASE
|
||||
assert hasattr(rippling, "detail") and not hasattr(rippling, "page")
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""The SuccessFactors host: `plugins/atshosts/successfactors.py` against saved
|
||||
"""The SuccessFactors host: `plugins/readers/successfactors.py` against saved
|
||||
career-site pages. No network. The fixtures are trimmed pages of Vestas and
|
||||
SAP (table layout), Demant and Scania (tile layout), Teradyne (a shared site
|
||||
with a path prefix), and the job pages of Vestas (`addressCountry`),
|
||||
@@ -19,8 +19,8 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs.discover import boards_in # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import successfactors # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import successfactors # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
@@ -439,7 +439,7 @@ def test_careers_url_and_robots_page_are_the_search_page() -> None:
|
||||
|
||||
def test_the_module_is_case_sensitive_about_the_prefix() -> None:
|
||||
assert successfactors.KEEP_CASE is True
|
||||
assert atshosts.HOSTS["successfactors"] is successfactors
|
||||
assert readers.HOSTS["successfactors"] is successfactors
|
||||
assert successfactors._parts("jobs.teradyne.com/MiR") == ("jobs.teradyne.com", "/MiR")
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats # noqa: E402
|
||||
from plugins.atshosts import workday # noqa: E402
|
||||
from plugins.readers import workday # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
SLUG = "zendesk.wd1/zendesk"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""The host modules of `plugins/atshosts/` and what `plugins/ats.py` does for
|
||||
"""The host modules of `plugins/readers/` and what `plugins/ats.py` does for
|
||||
every host: the registry and its contract check, the fetch a host is handed,
|
||||
the per-role detail reads, robots.txt, and Lever's EU instance. No network —
|
||||
a fake host stands in where a behaviour belongs to no real host yet."""
|
||||
@@ -22,8 +22,8 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import lever # noqa: E402
|
||||
from plugins import ats, readers # noqa: E402
|
||||
from plugins.readers import lever # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
@@ -31,14 +31,14 @@ FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
# --------------------------------------------------------------- registry
|
||||
|
||||
def test_the_registry_finds_every_module() -> None:
|
||||
names = sorted(p.stem for p in (ROOT / "plugins" / "atshosts").glob("*.py")
|
||||
names = sorted(p.stem for p in (ROOT / "plugins" / "readers").glob("*.py")
|
||||
if not p.stem.startswith("_"))
|
||||
assert sorted(atshosts.HOSTS) == names
|
||||
assert sorted(readers.HOSTS) == names
|
||||
assert set(names) >= {"greenhouse", "lever", "ashby", "workable", "smartrecruiters",
|
||||
"recruitee", "personio", "teamtailor"}
|
||||
assert all(not atshosts.problems(module, name) for name, module in atshosts.HOSTS.items())
|
||||
assert all(not readers.problems(module, name) for name, module in readers.HOSTS.items())
|
||||
# The Sources page's select and the plugin's description follow the modules.
|
||||
assert {name: module.LABEL for name, module in atshosts.HOSTS.items()} == ats.HOSTS
|
||||
assert {name: module.LABEL for name, module in readers.HOSTS.items()} == ats.HOSTS
|
||||
assert "Teamtailor" in ats.ATSSource.description
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ def test_the_registry_loads_a_package_by_name_and_skips_private_modules(
|
||||
path = _package(tmp_path, monkeypatch, "hostsok", {
|
||||
"zeta": _GOOD.format(name="zeta"), "alpha": _GOOD.format(name="alpha"),
|
||||
"_helpers": "X = 1\n"})
|
||||
assert list(atshosts.load(path, "hostsok")) == ["alpha", "zeta"]
|
||||
assert list(readers.load(path, "hostsok")) == ["alpha", "zeta"]
|
||||
|
||||
|
||||
def test_the_registry_orders_by_rank_then_name(
|
||||
@@ -95,7 +95,7 @@ def test_the_registry_orders_by_rank_then_name(
|
||||
"alpha": _GOOD.format(name="alpha"), # the default, 100
|
||||
"beta": _GOOD.format(name="beta") + "RANK = 5\n",
|
||||
"gamma": _GOOD.format(name="gamma") + "RANK = 100\n"})
|
||||
assert list(atshosts.load(path, "hostsranked")) == ["beta", "alpha", "gamma"]
|
||||
assert list(readers.load(path, "hostsranked")) == ["beta", "alpha", "gamma"]
|
||||
|
||||
|
||||
def test_the_eight_first_hosts_keep_the_order_they_had_before_modules() -> None:
|
||||
@@ -107,8 +107,8 @@ def test_the_eight_first_hosts_keep_the_order_they_had_before_modules() -> None:
|
||||
assert ats.ATSSource.description.startswith(
|
||||
"Company job boards: Greenhouse, Lever, Ashby, Workable, SmartRecruiters, "
|
||||
"Recruitee, Personio, Teamtailor")
|
||||
assert all(module.RANK < atshosts.DEFAULT_RANK
|
||||
for name, module in atshosts.HOSTS.items() if name in first)
|
||||
assert all(module.RANK < readers.DEFAULT_RANK
|
||||
for name, module in readers.HOSTS.items() if name in first)
|
||||
|
||||
|
||||
def test_the_registry_refuses_a_module_missing_a_required_name(
|
||||
@@ -116,7 +116,7 @@ def test_the_registry_refuses_a_module_missing_a_required_name(
|
||||
broken = _GOOD.format(name="broken").replace("def careers_url", "def not_careers_url")
|
||||
path = _package(tmp_path, monkeypatch, "hostsbad", {"broken": broken})
|
||||
with pytest.raises(ImportError, match=r"hostsbad\.broken .*no careers_url"):
|
||||
atshosts.load(path, "hostsbad")
|
||||
readers.load(path, "hostsbad")
|
||||
|
||||
|
||||
def test_the_contract_check_names_each_problem() -> None:
|
||||
@@ -126,7 +126,7 @@ def test_the_contract_check_names_each_problem() -> None:
|
||||
module.page = lambda get, slug, cursor: None
|
||||
module.probe_ok = lambda body: True
|
||||
module.RANK, module.KEEP_CASE = "1", "yes"
|
||||
found = atshosts.problems(module, "odd")
|
||||
found = readers.problems(module, "odd")
|
||||
assert "NAME is 'other', not the module's name 'odd'" in found
|
||||
assert "LABEL is not a non-empty string" in found
|
||||
assert any(p.startswith("PATTERNS has '('") for p in found)
|
||||
@@ -294,7 +294,7 @@ def web(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]:
|
||||
|
||||
def _run(monkeypatch: pytest.MonkeyPatch, module: types.ModuleType,
|
||||
state: dict[str, str] | None = None) -> tuple[list[Any], Any]:
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", module)
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", module)
|
||||
source = ats.ATSSource({"boards": [{"url": "fake:acme", "label": "Acme"}], "run": "r"})
|
||||
if state is not None:
|
||||
source.state = state
|
||||
@@ -411,7 +411,7 @@ def test_an_incomplete_listing_keeps_the_ids_it_did_not_list(
|
||||
base = "https://jobs.fake.example/acme"
|
||||
web["answers"].update({f"{base}/list": b'["2"]'})
|
||||
monkeypatch.setattr(ats, "_fetch_rows", lambda client, target: (
|
||||
atshosts.HOSTS["fake"].parse(b'["2"]', "acme"), False))
|
||||
readers.HOSTS["fake"].parse(b'["2"]', "acme"), False))
|
||||
state = {"ats:detailed:fake:acme": json.dumps(["fake:acme:1", "fake:acme:2"])}
|
||||
_items, state = _run(monkeypatch, _fake_host(detail=_detail), state)
|
||||
assert json.loads(state["ats:detailed:fake:acme"]) == ["fake:acme:1", "fake:acme:2"]
|
||||
@@ -422,7 +422,7 @@ def test_fetch_board_reads_the_listing_only(
|
||||
monkeypatch: pytest.MonkeyPatch, web: dict[str, Any]) -> None:
|
||||
base = "https://jobs.fake.example/acme"
|
||||
web["answers"].update({f"{base}/list": b'["1"]', f"{base}/1": b"one"})
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(detail=_detail))
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", _fake_host(detail=_detail))
|
||||
rows, complete = ats.fetch_board("fake:acme")
|
||||
assert ([r["description"] for r in rows], complete) == (["teaser"], True)
|
||||
assert web["asked"] == [f"{base}/list"]
|
||||
@@ -534,7 +534,7 @@ def _paged_host() -> types.ModuleType:
|
||||
|
||||
module.page = page
|
||||
module.rows = lambda ids, slug: _fake_host().parse(json.dumps(ids).encode(), slug)
|
||||
assert not atshosts.problems(module, "fake")
|
||||
assert not readers.problems(module, "fake")
|
||||
return module
|
||||
|
||||
|
||||
@@ -574,7 +574,7 @@ def test_a_pull_stopped_half_way_through_a_board_keeps_no_detail_ids(
|
||||
stored, is read again on the next pull."""
|
||||
base = "https://jobs.fake.example/acme"
|
||||
web["answers"].update({f"{base}/list": b'["1", "2"]', f"{base}/1": b"one", f"{base}/2": b"two"})
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(detail=_detail))
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", _fake_host(detail=_detail))
|
||||
source = ats.ATSSource({"boards": [{"url": "fake:acme", "label": "Acme"}], "run": "r"})
|
||||
roles: Any = source.fetch() # a generator, which `close` stops
|
||||
assert next(roles).body == "one"
|
||||
@@ -728,7 +728,7 @@ def _robots_site(location: str) -> Callable[[httpx.Request], httpx.Response]:
|
||||
|
||||
def test_a_robots_txt_redirect_to_the_www_twin_is_followed(
|
||||
monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(robots=True))
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", _fake_host(robots=True))
|
||||
with _client(_robots_site("https://www.jobs.fake.example/robots.txt")) as client, \
|
||||
pytest.raises(ats._Disallowed):
|
||||
ats._check_robots(client, "fake:acme", {})
|
||||
@@ -740,13 +740,13 @@ def test_a_robots_txt_redirect_to_the_www_twin_is_followed(
|
||||
])
|
||||
def test_a_robots_txt_redirect_anywhere_else_is_unreachable(
|
||||
monkeypatch: pytest.MonkeyPatch, location: str) -> None:
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(robots=True))
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", _fake_host(robots=True))
|
||||
with _client(_robots_site(location)) as client, pytest.raises(ats._RobotsUnreachable):
|
||||
ats._check_robots(client, "fake:acme", {})
|
||||
|
||||
|
||||
def test_the_www_twin_is_for_robots_txt_only(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(robots=True))
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", _fake_host(robots=True))
|
||||
with _client(_robots_site("https://www.jobs.fake.example/robots.txt")) as client, \
|
||||
pytest.raises(ats._Refused):
|
||||
ats._get(client, ROBOTS, "fake", "acme")
|
||||
@@ -756,7 +756,7 @@ def test_fetch_board_honours_robots_txt(
|
||||
monkeypatch: pytest.MonkeyPatch, web: dict[str, Any]) -> None:
|
||||
web["answers"].update({ROBOTS: b"User-agent: *\nDisallow: /\n",
|
||||
"https://jobs.fake.example/acme/list": b'["1"]'})
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(robots=True))
|
||||
monkeypatch.setitem(readers.HOSTS, "fake", _fake_host(robots=True))
|
||||
with pytest.raises(ats._Disallowed) as caught:
|
||||
ats.fetch_board("fake:acme")
|
||||
assert ats.failure_reason(caught.value) == "robots.txt disallows it"
|
||||
Reference in new issue
Block a user