Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
 def test_getting_zero_size(self):
     collection = uservoice.Collection(self.clientWithEmptySet,
                                       '/api/v1/suggestions')
     self.assertEqual(len(collection), 0)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 def test_correct_size_with_paged_client(self):
     collection = uservoice.Collection(self.pagedClient,
                                       '/api/v1/suggestions')
     self.assertEqual(len(collection), ELEMENTS)
Exemplo n.º 9
0
 def test_len_of_1(self):
     collection = uservoice.Collection(self.clientWithOne,
                                       '/api/v1/suggestions')
     self.assertEqual(len(collection), 1)
Exemplo n.º 10
0
 def test_getting_one_element(self):
     collection = uservoice.Collection(self.clientWithOne,
                                       '/api/v1/suggestions')
     self.assertEqual(collection[0]['id'], 1)
Exemplo n.º 11
0
 def test_enumerating_zero_elements(self):
     collection = uservoice.Collection(self.clientWithEmptySet,
                                       '/api/v1/suggestions')
     for i in collection:
         raise IndexError
Exemplo n.º 12
0
 def get_collection(self, path, **opts):
     return uservoice.Collection(self, path, **opts)