예제 #1
0
 def it_keeps_iterating_if_called_with_scroll_param(self):  # noqa
     page1 = users_scroll(include_users=True)
     page2 = users_scroll(include_users=False)
     side_effect = [page1, page2]
     with patch.object(Client, 'get',
                       side_effect=side_effect) as mock_method:  # noqa
         scroll = self.client.users.scroll()
         scroll.get_page()
         scroll.get_page('da6bbbac-25f6-4f07-866b-b911082d7')
         emails = [user['email'] for user in scroll.resources]
         eq_(emails, [])  # noqa
예제 #2
0
 def it_works_with_an_empty_list(self):  # noqa
     body = users_scroll(include_users=False)
     with patch.object(Client, 'get',
                       return_value=body) as mock_method:  # noqa
         scroll = self.client.users.scroll()
         scroll.get_page()
         emails = [user['email'] for user in scroll.resources]
         eq_(emails, [])  # noqa
예제 #3
0
 def it_keeps_iterating_if_users_returned(self):  # noqa
     page1 = users_scroll(include_users=True)
     page2 = users_scroll(include_users=False)
     side_effect = [page1, page2]
     with patch.object(Client, 'get',
                       side_effect=side_effect) as mock_method:  # noqa
         emails = [user.email for user in self.client.users.scroll()]
         eq_(
             [
                 call('/users/scroll', {}),
                 call('/users/scroll',
                      {'scroll_param': 'da6bbbac-25f6-4f07-866b-b911082d7'})
             ],  # noqa
             mock_method.mock_calls)
         eq_(emails, [
             '*****@*****.**', '*****@*****.**', '*****@*****.**'
         ])  # noqa
예제 #4
0
 def it_returns_one_page_scroll(self):  # noqa
     body = users_scroll(include_users=True)
     with patch.object(Client, 'get', return_value=body):
         scroll = self.client.users.scroll()
         scroll.get_next_page()
         emails = [user['email'] for user in scroll.resources]
         eq_(emails, [
             '*****@*****.**', '*****@*****.**', '*****@*****.**'
         ])  # noqa
예제 #5
0
 def it_supports_indexed_array_access(self):  # noqa
     body = users_scroll(include_users=True)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         eq_(self.client.users.scroll()[0].email, '*****@*****.**')
         mock_method.assert_called_once_with('/users/scroll', {})
         eq_(self.client.users.scroll()[1].email, '*****@*****.**')
예제 #6
0
 def it_stops_iterating_if_no_users_returned(self):  # noqa
     body = users_scroll(include_users=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         emails = [user.email for user in self.client.users.scroll()]
         mock_method.assert_called('/users/scroll', {})
         eq_(emails, [])  # noqa