Handle the cursor value '0000' on the last page
Search API will return cursor value '0000' on the last page to align with the List API. Quit the search API while cursor value is '0000' The upper requirements value for coverage was bump to 7.11.0 last week. 7.11.0 supports python 3.10 and above. Changed zuul.yaml to run the py310 job instead of the py39 job Change-Id: I2aa2e7e5f3e22c2cfd2a678d161709f14371664e
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
check:
|
||||
jobs:
|
||||
- openstack-tox-pep8
|
||||
- openstack-tox-py39
|
||||
- openstack-tox-py310
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-pep8
|
||||
- openstack-tox-py39
|
||||
- openstack-tox-py310
|
||||
|
||||
@@ -2008,6 +2008,25 @@ class TestNsxSearch(nsxlib_testcase.NsxClientTestCase):
|
||||
self.assertEqual(3, len(results))
|
||||
self.assertEqual([{"id": "s1"}, {"id": "s2"}, {"id": "s3"}], results)
|
||||
|
||||
def test_nsx_search_all_cursor_0(self):
|
||||
"""Test search all base method."""
|
||||
mock_search = mock.Mock()
|
||||
mock_search.side_effect = [
|
||||
{"cursor": "2",
|
||||
"result_count": 3,
|
||||
"results": [{"id": "s1"}, {"id": "s2"}]},
|
||||
{"cursor": "0",
|
||||
"result_count": 3,
|
||||
"results": [{"id": "s3"}]}]
|
||||
args = "foo"
|
||||
kwargs = {"a1": "v1", "a2": "v2"}
|
||||
results = self.nsxlib._search_all(mock_search, *args, **kwargs)
|
||||
mock_search.assert_has_calls([
|
||||
mock.call(*args, cursor=0, page_size=None, **kwargs),
|
||||
mock.call(*args, cursor=2, page_size=None, **kwargs)])
|
||||
self.assertEqual(3, len(results))
|
||||
self.assertEqual([{"id": "s1"}, {"id": "s2"}, {"id": "s3"}], results)
|
||||
|
||||
def test_nsx_search_all_safe_max_rs_ok(self):
|
||||
"""Test search all base method."""
|
||||
mock_search = mock.Mock()
|
||||
|
||||
@@ -295,7 +295,7 @@ class NsxLibBase(object, metaclass=abc.ABCMeta):
|
||||
if safe_mode and result_count > max_rs:
|
||||
raise exceptions.SearchResultsetTooLarge(
|
||||
result_count=result_count)
|
||||
if cursor >= result_count:
|
||||
if cursor >= result_count or cursor == 0:
|
||||
return results
|
||||
|
||||
def search_all_by_tags(self, tags, resource_type=None, **extra_attrs):
|
||||
|
||||
Reference in New Issue
Block a user