|
4 | 4 |
|
5 | 5 |
|
6 | 6 | class TestEndpoints(TestAdmin): |
| 7 | + def test_get_endpoints_iterator(self): |
| 8 | + """ Test to get endpoints iterator |
| 9 | + """ |
| 10 | + iterator = self.client_list.get_endpoints_iterator() |
| 11 | + response = next(iterator) |
| 12 | + self.assertEqual(response['method'], 'GET') |
| 13 | + (uri, args) = response['uri'].split('?') |
| 14 | + self.assertEqual(uri, '/admin/v1/endpoints') |
| 15 | + self.assertEqual( |
| 16 | + util.params_to_dict(args), |
| 17 | + { |
| 18 | + 'account_id': [self.client.account_id], |
| 19 | + 'limit': ['100'], |
| 20 | + 'offset': ['0'], |
| 21 | + }) |
| 22 | + |
7 | 23 | def test_get_endpoints(self): |
8 | | - response = self.client.get_endpoints() |
| 24 | + """ Test to get endpoints. |
| 25 | + """ |
| 26 | + response = self.client_list.get_endpoints()[0] |
| 27 | + self.assertEqual(response['method'], 'GET') |
| 28 | + (uri, args) = response['uri'].split('?') |
| 29 | + self.assertEqual(uri, '/admin/v1/endpoints') |
| 30 | + self.assertEqual( |
| 31 | + util.params_to_dict(args), |
| 32 | + { |
| 33 | + 'account_id': [self.client.account_id], |
| 34 | + 'limit': ['100'], |
| 35 | + 'offset': ['0'], |
| 36 | + }) |
| 37 | + |
| 38 | + def test_get_endpoints_offset(self): |
| 39 | + """ Test to get endpoints with pagination params. |
| 40 | + """ |
| 41 | + response = self.client_list.get_endpoints(offset=20)[0] |
| 42 | + self.assertEqual(response['method'], 'GET') |
| 43 | + (uri, args) = response['uri'].split('?') |
| 44 | + self.assertEqual(uri, '/admin/v1/endpoints') |
| 45 | + self.assertEqual( |
| 46 | + util.params_to_dict(args), |
| 47 | + { |
| 48 | + 'account_id': [self.client.account_id], |
| 49 | + 'limit': ['100'], |
| 50 | + 'offset': ['0'], |
| 51 | + }) |
| 52 | + |
| 53 | + def test_get_endpoints_limit(self): |
| 54 | + """ Test to get endpoints with pagination params. |
| 55 | + """ |
| 56 | + response = self.client_list.get_endpoints(limit=20)[0] |
9 | 57 | self.assertEqual(response['method'], 'GET') |
10 | 58 | (uri, args) = response['uri'].split('?') |
11 | 59 | self.assertEqual(uri, '/admin/v1/endpoints') |
12 | 60 | self.assertEqual( |
13 | 61 | util.params_to_dict(args), |
14 | | - {'account_id': [self.client.account_id]}) |
| 62 | + { |
| 63 | + 'account_id': [self.client.account_id], |
| 64 | + 'limit': ['20'], |
| 65 | + 'offset': ['0'], |
| 66 | + }) |
| 67 | + |
| 68 | + def test_get_endpoints_limit_and_offset(self): |
| 69 | + """ Test to get endpoints with pagination params. |
| 70 | + """ |
| 71 | + response = self.client_list.get_endpoints(limit=35, offset=20)[0] |
| 72 | + self.assertEqual(response['method'], 'GET') |
| 73 | + (uri, args) = response['uri'].split('?') |
| 74 | + self.assertEqual(uri, '/admin/v1/endpoints') |
| 75 | + self.assertEqual( |
| 76 | + util.params_to_dict(args), |
| 77 | + { |
| 78 | + 'account_id': [self.client.account_id], |
| 79 | + 'limit': ['35'], |
| 80 | + 'offset': ['20'], |
| 81 | + }) |
| 82 | + |
| 83 | + |
| 84 | +if __name__ == '__main__': |
| 85 | + unittest.main() |
0 commit comments