Skip to content

Commit

Permalink
PaginatedResponse cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkubi committed Sep 25, 2022
1 parent 272df0c commit 81598e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions pydactyl/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class PaginatedResponse(object):

def __init__(self, client, endpoint, data):
self._client = client
self._initial_data = data['data']
self.data = data['data']
self.endpoint = endpoint
self.meta = data['meta']
Expand All @@ -25,7 +24,6 @@ def __iter__(self):
self._iteration = 0
return self


def __next__(self):
""""Retrieves the next page of results.
Expand All @@ -38,6 +36,7 @@ def __next__(self):
"""
self._iteration += 1
if self._iteration == 1:
# PaginatedResponses are initialized with the first page of results
return self
if self._next_page_exists(self.meta):
params = {'page': self._iteration}
Expand Down
6 changes: 3 additions & 3 deletions tests/base/responses_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_META}

MULTIPAGE_TEST_DATA = [
{'data': ['thing1', 'thing2'], 'meta': TEST_META},
{'data': ['thing1', 'thing2', 'sometimespage1isweird'], 'meta': TEST_META},
{'data': ['thing3', 'thing4'], 'meta': TEST_META},
{'data': ['thing84', 'thing97', 'fdas', 'pepperoni'], 'meta': TEST_META},
{'data': ['one', 'two', 'three', 4, 5, '6'], 'meta': TEST_META},
{'data': ['lkjskljd'], 'meta': TEST_META},
{'data': ['pineappleisanacceptablepizzatopping'], 'meta': TEST_META},
]


Expand Down Expand Up @@ -114,6 +114,6 @@ def test_paginated_response_has_correct_number_of_items(self):
MULTIPAGE_TEST_DATA[0])
expected = [item for data in MULTIPAGE_TEST_DATA for item in
data['data']]
expected_count = 15
expected_count = 16
self.assertEqual(expected_count, len(expected))
self.assertEqual(expected_count, len(response.collect()))

0 comments on commit 81598e3

Please sign in to comment.