Skip to content

Commit 4419d87

Browse files
committed
test: separate non-paging tests
1 parent 39cc8af commit 4419d87

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

tests/unit/test_pageiterator.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,40 +58,6 @@ def side_effect(_, link, **kwargs):
5858
assert req.call_count >= math.ceil(call_count)
5959

6060

61-
def test_no_paging_required():
62-
"""If "next" link not present, current items should be included."""
63-
64-
items = [{"name": "a"}, {"name": "b"}, {"name": "c"}]
65-
obj = RestObj(items=items, count=len(items))
66-
67-
with mock.patch("sasctl.core.request") as req:
68-
# Mock appears to be *sometimes* shared with mock created in `paging` fixture
69-
# above. Depending on execution order, this can result in calls to the mock
70-
# made by other tests to be counted here. Explicitly reset to prevent this.
71-
req.reset_mock()
72-
try:
73-
req.assert_not_called()
74-
except AssertionError as e:
75-
raise AssertionError(
76-
f"method_calls={req.mock_calls} call_args={req.call_args_list}"
77-
)
78-
79-
pager = PageIterator(obj)
80-
81-
# Returned page of items should preserve item order
82-
items = next(pager)
83-
for idx, item in enumerate(items):
84-
assert item.name == RestObj(items[idx]).name
85-
86-
# No req should have been made to retrieve additional data.
87-
try:
88-
req.assert_not_called()
89-
except AssertionError as e:
90-
raise AssertionError(
91-
f"method_calls={req.mock_calls} call_args={req.call_args_list}"
92-
)
93-
94-
9561
def test_paging_required(paging):
9662
"""Requests should be made to retrieve additional pages."""
9763
obj, items, _ = paging
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from unittest import mock
2+
3+
from sasctl.core import PageIterator, RestObj
4+
5+
6+
def test_no_paging_required():
7+
"""If "next" link not present, current items should be included."""
8+
9+
items = [{"name": "a"}, {"name": "b"}, {"name": "c"}]
10+
obj = RestObj(items=items, count=len(items))
11+
12+
with mock.patch("sasctl.core.request") as req:
13+
pager = PageIterator(obj)
14+
15+
# Returned page of items should preserve item order
16+
items = next(pager)
17+
for idx, item in enumerate(items):
18+
assert item.name == RestObj(items[idx]).name
19+
20+
# No req should have been made to retrieve additional data.
21+
try:
22+
req.assert_not_called()
23+
except AssertionError as e:
24+
raise AssertionError(
25+
f"method_calls={req.mock_calls} call_args={req.call_args_list}"
26+
)

0 commit comments

Comments
 (0)