How to use the groupy.pagers.GroupList function in groupy

To help you get started, we’ve selected a few groupy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rhgrant10 / Groupy / tests / api / test_groups.py View on Github external
def test_results_is_a_GroupList(self):
        self.assertTrue(isinstance(self.results, pagers.GroupList))
github rhgrant10 / Groupy / tests / test_pagers.py View on Github external
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']
github rhgrant10 / Groupy / groupy / managers.py View on Github external
def list(self, **params):
        return pagers.GroupList(self, **params)
github rhgrant10 / Groupy / groupy / api / groups.py View on Github external
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)
github rhgrant10 / Groupy / groupy / pagers.py View on Github external
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,
    }