[pagination tests] Do not fail on zero resources

Since the tests running in parallel, when resources
are deleted by concurrent tests, GET call can return
0 resources, adjust tests to not fail when there are
0 items returned.

This is in continuation of previous patch[1].

[1] https://review.opendev.org/926201

Related-Bug: #2076328
Change-Id: I37c1a3855cb5c37aadec5cda26c89cd3f99e074f
This commit is contained in:
yatinkarel 2024-08-26 16:40:38 +05:30
parent 20dec4e823
commit a8c221ca48

View File

@ -1544,7 +1544,9 @@ class BaseSearchCriteriaTest(BaseNetworkTest):
pagination_args['marker'] = resources[-1]['id']
body = self.list_method(**pagination_args)
resources_ = self._extract_resources(body)
self.assertEqual(1, len(resources_))
# Empty resource list can be returned when any concurrent
# tests delete them
self.assertGreaterEqual(1, len(resources_))
resources.extend(resources_)
return self._test_resources(resources)
@ -1569,7 +1571,9 @@ class BaseSearchCriteriaTest(BaseNetworkTest):
self.plural_name, uri
)
resources_ = self._extract_resources(body)
self.assertEqual(1, len(resources_))
# Empty resource list can be returned when any concurrent
# tests delete them
self.assertGreaterEqual(1, len(resources_))
resources.extend(self._test_resources(resources_))
# The last element is empty and does not contain 'next' link
@ -1587,7 +1591,9 @@ class BaseSearchCriteriaTest(BaseNetworkTest):
self.plural_name, uri
)
resources_ = self._extract_resources(body)
self.assertEqual(1, len(resources_))
# Empty resource list can be returned when any concurrent
# tests delete them
self.assertGreaterEqual(1, len(resources_))
resources2.extend(self._test_resources(resources_))
self.assertSameOrder(resources, reversed(resources2))