CP-2451 fix tests

This commit is contained in:
Rodrigo Rodrigues 2026-01-22 09:56:49 +00:00
parent 3ad6e074bf
commit 3182612069

View File

@ -14,8 +14,7 @@ def test_iterator_uses_cursor_from_next_href():
else: else:
links = SimpleNamespace(next=None) links = SimpleNamespace(next=None)
items = ["third"] items = ["third"]
data = SimpleNamespace(links=links) return SimpleNamespace(links=links, items=items)
return SimpleNamespace(data=data, items=items)
responses = list(PaginatorIterator(method, lambda response: response.items)) responses = list(PaginatorIterator(method, lambda response: response.items))
@ -29,12 +28,12 @@ def test_iterator_reads_cursor_from_links_mapping():
def method(**params): def method(**params):
calls.append(params.copy()) calls.append(params.copy())
if params.get("pageCursor") is None: if params.get("pageCursor") is None:
data = {"_links": {"next": {"href": "https://example.com?foo=1&pageCursor=xyz"}}} links = {"next": {"href": "https://example.com?foo=1&pageCursor=xyz"}}
items = ["alpha"] items = ["alpha"]
else: else:
data = {"_links": {"next": None}} links = {"next": None}
items = ["beta"] items = ["beta"]
return SimpleNamespace(data=data, items=items) return SimpleNamespace(links=links, items=items)
responses = list(PaginatorIterator(method, lambda response: response.items, cursor_param="pageCursor")) responses = list(PaginatorIterator(method, lambda response: response.items, cursor_param="pageCursor"))
@ -48,12 +47,12 @@ def test_iterator_stops_when_no_cursor_param_present():
def method(**params): def method(**params):
calls.append(params.copy()) calls.append(params.copy())
if params.get("cursor") is None: if params.get("cursor") is None:
data = {"links": {"next": "/next/page"}} links = {"next": "/next/page"}
items = ["one"] items = ["one"]
else: else:
data = {"links": {"next": None}} links = {"next": None}
items = ["two"] items = ["two"]
return SimpleNamespace(data=data, items=items) return SimpleNamespace(links=links, items=items)
responses = list(PaginatorIterator(method, lambda response: response.items)) responses = list(PaginatorIterator(method, lambda response: response.items))
@ -66,8 +65,8 @@ def test_iterator_stops_on_repeated_cursor():
def method(**params): def method(**params):
calls.append(params.copy()) calls.append(params.copy())
data = {"links": {"next": "https://example.com?cursor=same"}} links = {"next": "https://example.com?cursor=same"}
return SimpleNamespace(data=data, items=["only"]) return SimpleNamespace(links=links, items=["only"])
responses = list(PaginatorIterator(method, lambda response: response.items, cursor="same")) responses = list(PaginatorIterator(method, lambda response: response.items, cursor="same"))