Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_results_is_a_GroupList(self):
self.assertTrue(isinstance(self.results, pagers.GroupList))
def setUp(self):
m_manager = mock.Mock()
m_endpoint = mock.Mock()
self.groups = pagers.GroupList(m_manager, m_endpoint)
self.page = self.groups.params['page']
def list(self, **params):
return pagers.GroupList(self, **params)
def list(self, page=1, per_page=10, omit=None):
"""List groups by page.
The API allows certain fields to be excluded from the results so that
very large groups can be fetched without exceeding the maximum
response size. At the time of this writing, only 'memberships' is
supported.
:param int page: page number
:param int per_page: number of groups per page
:param int omit: a comma-separated list of fields to exclude
:return: a list of groups
:rtype: :class:`~groupy.pagers.GroupList`
"""
return pagers.GroupList(self, self._raw_list, page=page,
per_page=per_page, omit=omit)
while self.items:
yield from self.items
self.items = self.fetch_next()
class GroupList(Pager):
"""Pager for groups."""
#: default to the first page
default_params = {'page': 1}
def set_next_page_params(self):
self.params['page'] += 1
class ChatList(GroupList):
pass
class MessageList(Pager):
"""Pager for messages."""
#: the default mode param
default_mode = 'before_id'
#: all possible mode params and the index for their next page params
modes = {
'before_id': -1,
'after_id': -1,
'since_id': 0,
}