Guard every read that is not a sweep, treat a read that asks nothing as incomplete, and mark a filtered read that could not ask remote, so no board loses its roles to a changed answer or a filter it could not send
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e827665dd
commit
36bc639384
4 files changed
+332
-116
No files matched your search
+7
-17
@@ -103,8 +103,6 @@ def test_ask_for_narrows_the_params_to_the_declared_filters() -> None:
|
||||
both = _whole(filters=Filters(country="many", remote="many"))
|
||||
ask = _runner.ask_for(both, {"countries": ["DE"]}, {"countries": ["DK"], "remote": True})
|
||||
assert (ask.countries, ask.remote) == (("DE",), True)
|
||||
# A module without READS reads the whole board.
|
||||
assert _runner.ask_for(types.ModuleType("old"), {"countries": ["DK"]}) == Ask()
|
||||
|
||||
|
||||
def test_a_searchs_params_go_whole_into_the_ask_with_its_key(
|
||||
@@ -139,11 +137,12 @@ def test_ids_filters_are_mapped_through_the_facets() -> None:
|
||||
ask = Ask(countries=("DK", "XX"))
|
||||
[mapped] = _runner.series(module, ask, {"country": {"DK": "h-1", "SE": "h-2"}})
|
||||
assert mapped.countries == ("h-1",)
|
||||
# None known: the host has nothing in reach, and the read is empty.
|
||||
# None known: nothing is asked, which is no evidence, so the read is
|
||||
# incomplete and closes nothing.
|
||||
assert _runner.series(module, Ask(countries=("XX",)), {"country": {"DK": "h-1"}}) == []
|
||||
listing = _runner.read_listing(module, "acme", Web(), Ask(countries=("XX",)),
|
||||
facets={"country": {}})
|
||||
assert (listing.rows, listing.complete, listing.filtered) == ([], True, True)
|
||||
assert (listing.rows, listing.complete, listing.filtered) == ([], False, True)
|
||||
|
||||
|
||||
def test_facets_are_asked_once_a_day_and_only_for_an_ids_filter() -> None:
|
||||
@@ -189,17 +188,6 @@ def test_a_body_over_the_cap_is_read_again_at_the_fallback_feed() -> None:
|
||||
_runner.read_listing(module, "acme", web)
|
||||
|
||||
|
||||
def test_a_module_without_reads_gets_the_older_signatures() -> None:
|
||||
module: Any = types.ModuleType("old")
|
||||
module.NAME = "old"
|
||||
module.feed_url = lambda slug: f"https://jobs.fake.example/{slug}/list"
|
||||
module.parse = lambda body, slug: [_row(i) for i in json.loads(body)]
|
||||
listing = _runner.read_listing(module, "acme",
|
||||
Web({"https://jobs.fake.example/acme/list": b'["1"]'}),
|
||||
Ask(countries=("DK",)))
|
||||
assert [r["source_id"] for r in listing.rows] == ["1"] and listing.complete
|
||||
|
||||
|
||||
def test_a_paged_board_with_a_total_is_complete_when_it_read_as_many() -> None:
|
||||
pages = [["1", "2"], ["3"]]
|
||||
listing = _runner.read_listing(_paged(pages, total=3), "acme", _pages_web(pages),
|
||||
@@ -333,9 +321,11 @@ def test_a_suspect_read_far_under_the_last_count_fails() -> None:
|
||||
web.answers["https://jobs.fake.example/acme/list"] = b'["1"]'
|
||||
with pytest.raises(_runner.Suspect, match="under 10% of the 20"):
|
||||
_runner.read(state, "ats", "t", module, "acme", web)
|
||||
# A reader whose empty answer is trusted reads it as it is.
|
||||
# A reader whose empty answer is trusted is held too, from a count of
|
||||
# `SUSPECT_MIN`.
|
||||
module.READS = module.READS.model_copy(update={"empty": "trusted"})
|
||||
assert _runner.read(state, "ats", "t", module, "acme", web).ids == ["1"]
|
||||
with pytest.raises(_runner.Suspect):
|
||||
_runner.read(state, "ats", "t", module, "acme", web)
|
||||
|
||||
|
||||
def test_the_guard_compares_only_reads_that_asked_the_same() -> None:
|
||||
|
||||
Reference in new issue
Block a user