Count a page of ids already read as a stall only where the host states no total or the reader hands the page over empty, so a resumed sweep reads on when the list grew at the top
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f37270eb3
commit
c4c17fb019
3 files changed
+39
-23
No files matched your search
+26
-8
@@ -215,15 +215,33 @@ def test_a_page_with_nothing_new_ends_the_read_incomplete() -> None:
|
||||
assert [index for index, _ in module.asked] == [0, 1]
|
||||
|
||||
|
||||
def test_a_page_with_nothing_new_is_a_stall_with_a_stated_total_too() -> None:
|
||||
"""A host that ignores the cursor and states a total used to be read on
|
||||
to the page cap; the second page, which adds nothing while the reader
|
||||
hands a cursor, ends it incomplete."""
|
||||
pages = [["1", "2"]] * 5
|
||||
module = _paged(pages, total=5)
|
||||
listing = _runner.read_listing(module, "acme", _pages_web(pages), limits=NO_DELAY)
|
||||
def test_an_empty_page_with_a_cursor_is_a_stall_with_a_stated_total_too() -> None:
|
||||
"""A reader that sees a page come again hands it over empty with a
|
||||
cursor, as SuccessFactors does. That ends the read incomplete, also when
|
||||
the host states a total, where it used to run on to the page cap."""
|
||||
module = _paged([["1", "2"]] * 5, total=5)
|
||||
seen: list[Any] = []
|
||||
|
||||
def page(get: Any, slug: str, cursor: Any, ask: Ask) -> Any:
|
||||
seen.append(cursor)
|
||||
return (["1", "2"], [{"id": "1"}, {"id": "2"}], 5, 1) if cursor is None \
|
||||
else ([], [], 5, cursor)
|
||||
|
||||
module.page = page
|
||||
listing = _runner.read_listing(module, "acme", Web(), limits=NO_DELAY)
|
||||
assert (listing.ids, listing.complete) == (["1", "2"], False)
|
||||
assert [index for index, _ in module.asked] == [0, 1]
|
||||
assert seen == [None, 1]
|
||||
|
||||
|
||||
def test_a_page_of_ids_already_read_is_no_stall_with_a_stated_total() -> None:
|
||||
"""What a resumed sweep starts on when the list grew at the top since:
|
||||
the page at the saved cursor holds only roles the sweep has. The read
|
||||
goes on to the roles behind them."""
|
||||
pages = [["1", "2"], ["1", "2"], ["3"]]
|
||||
module = _paged(pages, total=3)
|
||||
listing = _runner.read_listing(module, "acme", _pages_web(pages), limits=NO_DELAY)
|
||||
assert (listing.ids, listing.complete) == (["1", "2", "3"], True)
|
||||
assert [index for index, _ in module.asked] == [0, 1, 2]
|
||||
|
||||
|
||||
def test_an_empty_last_page_ends_a_read_without_a_total_complete() -> None:
|
||||
|
||||
Reference in new issue
Block a user