Fail the read when Lever answers something other than a list or Oracle an answer without its search wrapper, instead of reading an empty board that is complete

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-10-05 09:32:06 +02:00
1 parent 19fb73caa0
commit 85aed0807b
4 files changed
+67 -5

No files matched your search

+26 -1
View File
@@ -1,15 +1,20 @@
"""The Lever host module's places, country and employment, against a small
saved board. No network. The pay and the plain row are in `test_ats.py`."""
saved board, and an answer that is no board. No network. The pay and the
plain row are in `test_ats.py`."""
from __future__ import annotations
import json
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 plugins import ats # noqa: E402
from plugins.readers import Ask, lever # noqa: E402
BOARD = (ROOT / "tests" / "fixtures" / "ats" / "lever-places.json").read_bytes()
@@ -33,6 +38,26 @@ def test_the_commitment_is_the_hosts_word() -> None:
assert several["employment"] == "Full-time" and one["employment"] == "Permanent"
def test_an_answer_that_is_not_a_list_raises_and_an_empty_list_is_no_roles() -> None:
with pytest.raises(ValueError, match="JSON dict, not a list"):
lever.parse(b'{"ok": false, "error": "Document not found"}', "acme")
assert lever.parse(b"[]", "acme") == []
def test_an_error_document_with_a_200_fails_the_read_and_stamps_nothing(
monkeypatch: pytest.MonkeyPatch) -> None:
"""It used to read as a complete board with no roles, which the settle
closed whole under ten roles, where the 10% guard does not hold."""
monkeypatch.setattr(ats, "_get", lambda *a, **kw: b'{"ok": false}')
source = ats.ATSSource({"boards": [{"url": "lever:acme", "label": "Acme", "params": {}}],
"run": "r"})
source.state = {}
assert list(source.fetch()) == []
assert "ats:ok:lever:acme" not in source.state
assert json.loads(source.state["ats:failing:lever:acme"])["reason"].startswith(
"ValueError: Lever's answer is a JSON dict")
def test_it_declares_a_whole_listing_of_trusted_dates_and_its_robots_record() -> None:
reads = lever.READS
assert (reads.listing, reads.text, reads.places) == ("whole", "listing", "many")