def it_keeps_iterating_if_next_link(self):
     page1 = page_of_users(include_next_link=True)
     page2 = page_of_users(include_next_link=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.all()]
         eq_([call('/users', {}), call('https://api.intercom.io/users?per_page=50&page=2', {})],  # noqa
             mock_method.mock_calls)
         eq_(emails, ['*****@*****.**', '*****@*****.**', '*****@*****.**'] * 2)  # noqa
예제 #2
0
 def it_keeps_iterating_if_next_link(self):
     page1 = page_of_users(include_next_link=True)
     page2 = page_of_users(include_next_link=False)
     side_effect = [page1, page2]
     with patch.object(Intercom, 'get', side_effect=side_effect) as mock_method:  # noqa
         emails = [user.email for user in User.all()]
         eq_([call('/users'), call('https://api.intercom.io/users?per_page=50&page=2')],  # noqa
             mock_method.mock_calls)
         eq_(emails, ['*****@*****.**', '*****@*****.**', '*****@*****.**'] * 2)  # noqa
 def it_keeps_iterating_if_next_link(self):
     page1 = page_of_users(include_next_link=True)
     page2 = page_of_users(include_next_link=False)
     side_effect = [page1, page2]
     with patch.object(Intercom, "get", side_effect=side_effect) as mock_method:  # noqa
         emails = [user.email for user in User.all()]
         eq_(
             [call("/users"), call("https://api.intercom.io/users?per_page=50&page=2")],  # noqa
             mock_method.mock_calls,
         )
         eq_(emails, ["*****@*****.**", "*****@*****.**", "*****@*****.**"] * 2)  # noqa
 def it_stops_iterating_if_no_next_link(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         emails = [user.email for user in self.client.users.all()]
         mock_method.assert_called_once_with('/users', {})
         eq_(emails, [
             '*****@*****.**', '*****@*****.**', '*****@*****.**'
         ])  # noqa
 def it_supports_querying(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         emails = [
             user.email
             for user in self.client.users.find_all(tag_name='Taggart J')
         ]  # noqa
         eq_(emails, [
             '*****@*****.**', '*****@*****.**', '*****@*****.**'
         ])  # noqa
         mock_method.assert_called_once_with(
             '/users', {'tag_name': 'Taggart J'})  # noqa
 def it_supports_querying(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         emails = [user.email for user in self.client.users.find_all(tag_name='Taggart J')]  # noqa
         eq_(emails, ['*****@*****.**', '*****@*****.**', '*****@*****.**'])  # noqa
         mock_method.assert_called_once_with('/users', {'tag_name': 'Taggart J'})  # noqa
 def it_supports_indexed_array_access(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         eq_(self.client.users.all()[0].email, '*****@*****.**')
         mock_method.assert_called_once_with('/users', {})
 def it_stops_iterating_if_no_next_link(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         emails = [user.email for user in self.client.users.all()]
         mock_method.assert_called_once_with('/users', {})
         eq_(emails, ['*****@*****.**', '*****@*****.**', '*****@*****.**'])  # noqa
 def it_supports_querying(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Intercom, "get", return_value=body) as mock_method:
         emails = [user.email for user in User.find_all(tag_name="Taggart J")]  # noqa
         eq_(emails, ["*****@*****.**", "*****@*****.**", "*****@*****.**"])  # noqa
         mock_method.assert_called_once_with("/users", tag_name="Taggart J")
 def it_supports_indexed_array_access(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Intercom, "get", return_value=body) as mock_method:
         eq_(User.all()[0].email, "*****@*****.**")
         mock_method.assert_called_once_with("/users")
 def it_stops_iterating_if_no_next_link(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Intercom, "get", return_value=body) as mock_method:
         emails = [user.email for user in User.all()]
         mock_method.assert_called_once_with("/users")
         eq_(emails, ["*****@*****.**", "*****@*****.**", "*****@*****.**"])  # noqa
 def it_supports_indexed_array_access(self):
     body = page_of_users(include_next_link=False)
     with patch.object(Client, 'get', return_value=body) as mock_method:
         eq_(self.client.users.all()[0].email, '*****@*****.**')
         mock_method.assert_called_once_with('/users', {})
예제 #13
0
 def it_gets_users_by_tag(self):
     with patch.object(Client, 'get', return_value=page_of_users(False)):
         users = self.client.users.by_tag(124)
         for user in users:
             ok_(hasattr(user, 'avatar'))
예제 #14
0
 def it_gets_users_by_tag(self):
     with patch.object(Client, 'get', return_value=page_of_users(False)):
         users = self.client.users.by_tag(124)
         for user in users:
             ok_(hasattr(user, 'avatar'))