From ea50bd36437a77f7ce6e43c13513503389d07285 Mon Sep 17 00:00:00 2001 From: Ekaterina Chernova Date: Wed, 9 Sep 2015 16:06:44 +0300 Subject: [PATCH] Add id to sort keys parameters while pagination Currently default sort is a 'name'. But in case there are more packages in catalog with same name more then 'limit' parameter, all of them will be ignored. Adding additional sort key is fixing that problem. Change-Id: Idd86275dc48cbdb2862987f6e3151e1d9fb4e00f Closes-Bug: #1448782 --- murano/db/catalog/api.py | 2 +- murano/tests/unit/db/test_catalog.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/murano/db/catalog/api.py b/murano/db/catalog/api.py index 1d560018..66334202 100644 --- a/murano/db/catalog/api.py +++ b/murano/db/catalog/api.py @@ -324,7 +324,7 @@ def package_search(filters, context, limit=None, catalog=False): sort_keys = [SEARCH_MAPPING[sort_key] for sort_key in filters.get('order_by', ['name'])] - + sort_keys.append('id') marker = filters.get('marker') sort_dir = filters.get('sort_dir') diff --git a/murano/tests/unit/db/test_catalog.py b/murano/tests/unit/db/test_catalog.py index 7615e1cd..cdf223ae 100644 --- a/murano/tests/unit/db/test_catalog.py +++ b/murano/tests/unit/db/test_catalog.py @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest import uuid from oslo_db import exception as db_exception @@ -181,16 +180,16 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase): res = api.package_search({'marker': marker}, self.context, limit=4) self.assertEqual(len(res), 0) - @unittest.expectedFailure def test_pagination_loops_through_names(self): - """Creates 10 packages with the same name and iterates through them, + """Creates 10 packages with the same display name and iterates through them, checking that package are not skipped. """ - # TODO(kzaitsev): fix https://bugs.launchpad.net/murano/+bug/1448782 for dummy in range(10): - api.package_upload(self._stub_package( - fully_qualified_name=str(uuid.uuid4())), self.tenant_id) + api.package_upload( + self._stub_package(name='test', + fully_qualified_name=str(uuid.uuid4())), + self.tenant_id) res = api.package_search({}, self.context, limit=4) self.assertEqual(len(res), 4) marker = res[-1].id