summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit/test_base.py
diff options
context:
space:
mode:
authorGerhard Muntingh <gerhard@qux.nl>2017-05-16 21:03:48 +0200
committerGorka Eguileor <geguileo@redhat.com>2017-06-22 19:06:48 +0200
commitd11b1059a44501a76b4c604f30c9e17b437dce4b (patch)
tree407183f76b0c57a12c3e1e852ee222d0fdeefec5 /cinderclient/tests/unit/test_base.py
parentb910f5bea33cbccca25b008b3b03dc5dce27245a (diff)
downloadpython-cinderclient-d11b1059a44501a76b4c604f30c9e17b437dce4b.tar.gz
Add pagination for snapshots, backups
Allow cinderclient to retrieve more than osapi_max_limit (default 1000) snapshots, backups, etc. Cinder pagination support has been added to the API quite some time ago. Client support was only implemented for volumes. This commit allows other resources to be paginated as well. Change-Id: I9a6f446b680dadedccd14ba49efdef7f5ef0a58a Closes-Bug: #1691229 Co-Authored-By: Gorka Eguileor <geguileo@redhat.com>
Diffstat (limited to 'cinderclient/tests/unit/test_base.py')
-rw-r--r--cinderclient/tests/unit/test_base.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/test_base.py b/cinderclient/tests/unit/test_base.py
index ce8d9e4..d4dd517 100644
--- a/cinderclient/tests/unit/test_base.py
+++ b/cinderclient/tests/unit/test_base.py
@@ -126,6 +126,37 @@ class BaseTest(utils.TestCase):
manager._build_list_url,
**arguments)
+ def test__list_no_link(self):
+ api = mock.Mock()
+ api.client.get.return_value = (mock.sentinel.resp,
+ {'resp_keys': [{'name': '1'}]})
+ manager = test_utils.FakeManager(api)
+ res = manager._list(mock.sentinel.url, 'resp_keys')
+ api.client.get.assert_called_once_with(mock.sentinel.url)
+ result = [r.name for r in res]
+ self.assertListEqual(['1'], result)
+
+ def test__list_with_link(self):
+ api = mock.Mock()
+ api.client.get.side_effect = [
+ (mock.sentinel.resp,
+ {'resp_keys': [{'name': '1'}],
+ 'resp_keys_links': [{'rel': 'next', 'href': mock.sentinel.u2}]}),
+ (mock.sentinel.resp,
+ {'resp_keys': [{'name': '2'}],
+ 'resp_keys_links': [{'rel': 'next', 'href': mock.sentinel.u3}]}),
+ (mock.sentinel.resp,
+ {'resp_keys': [{'name': '3'}],
+ 'resp_keys_links': [{'rel': 'next', 'href': None}]}),
+ ]
+ manager = test_utils.FakeManager(api)
+ res = manager._list(mock.sentinel.url, 'resp_keys')
+ api.client.get.assert_has_calls([mock.call(mock.sentinel.url),
+ mock.call(mock.sentinel.u2),
+ mock.call(mock.sentinel.u3)])
+ result = [r.name for r in res]
+ self.assertListEqual(['1', '2', '3'], result)
+
class ListWithMetaTest(utils.TestCase):
def test_list_with_meta(self):