def test_yielding_once(self): collection = uservoice.Collection(self.clientWithOne, '/api/v1/suggestions') count = 0 for i in collection: count += 1 self.assertEqual(count, 1)
def test_yield_correct_number_of_times_with_paged_client(self): collection = uservoice.Collection(self.pagedClient, '/api/v1/suggestions') count = 0 for i in collection: count += 1 self.assertEqual(count, ELEMENTS)
def test_limited_size_with_paged_client_and_limit(self): collection = uservoice.Collection(self.pagedClient, '/api/v1/suggestions', limit=1001) def func(): collection[1001] self.assertRaises(IndexError, func)
def test_accessing_out_of_bounds_element_in_first_page_with_really_small_limited_size_with_paged_client( self): collection = uservoice.Collection(self.pagedClient, '/api/v1/suggestions', limit=2) def func(): collection[2] self.assertRaises(IndexError, func)
def test_getting_zero_size(self): collection = uservoice.Collection(self.clientWithEmptySet, '/api/v1/suggestions') self.assertEqual(len(collection), 0)
def test_accessing_element_in_first_page_with_really_small_limited_size_with_paged_client( self): collection = uservoice.Collection(self.pagedClient, '/api/v1/suggestions', limit=2) self.assertEqual(collection[1]['id'], 2)
def test_limited_size_with_paged_client_and_limit(self): collection = uservoice.Collection(self.pagedClient, '/api/v1/suggestions', limit=1001) self.assertEqual(len(collection), 1001)
def test_correct_size_with_paged_client(self): collection = uservoice.Collection(self.pagedClient, '/api/v1/suggestions') self.assertEqual(len(collection), ELEMENTS)
def test_len_of_1(self): collection = uservoice.Collection(self.clientWithOne, '/api/v1/suggestions') self.assertEqual(len(collection), 1)
def test_getting_one_element(self): collection = uservoice.Collection(self.clientWithOne, '/api/v1/suggestions') self.assertEqual(collection[0]['id'], 1)
def test_enumerating_zero_elements(self): collection = uservoice.Collection(self.clientWithEmptySet, '/api/v1/suggestions') for i in collection: raise IndexError
def get_collection(self, path, **opts): return uservoice.Collection(self, path, **opts)