diff --git a/openstack/resource2.py b/openstack/resource2.py index ab20c1ee..cffd4e50 100644 --- a/openstack/resource2.py +++ b/openstack/resource2.py @@ -190,8 +190,12 @@ class QueryParameters(object): :param mappings: Key-value pairs where the key is the client-side name we'll accept here and the value is the name the server expects, e.g, changes_since=changes-since + + By default, both limit and marker are included in the initial mapping + as they're the most common query parameters used for listing resources. """ - self._mapping = dict({name: name for name in names}, **mappings) + self._mapping = {"limit": "limit", "marker": "marker"} + self._mapping.update(dict({name: name for name in names}, **mappings)) def _transpose(self, query): """Transpose the keys in query based on the mapping diff --git a/openstack/tests/unit/compute/v2/test_flavor.py b/openstack/tests/unit/compute/v2/test_flavor.py index 70d73139..dba4a4aa 100644 --- a/openstack/tests/unit/compute/v2/test_flavor.py +++ b/openstack/tests/unit/compute/v2/test_flavor.py @@ -47,7 +47,9 @@ class TestFlavor(testtools.TestCase): self.assertDictEqual({"sort_key": "sort_key", "sort_dir": "sort_dir", "min_disk": "minDisk", - "min_ram": "minRam"}, + "min_ram": "minRam", + "limit": "limit", + "marker": "marker"}, sot._query_mapping._mapping) def test_make_basic(self): diff --git a/openstack/tests/unit/compute/v2/test_image.py b/openstack/tests/unit/compute/v2/test_image.py index 70e11a31..8e848a23 100644 --- a/openstack/tests/unit/compute/v2/test_image.py +++ b/openstack/tests/unit/compute/v2/test_image.py @@ -56,7 +56,9 @@ class TestImage(testtools.TestCase): "type": "type", "min_disk": "minDisk", "min_ram": "minRam", - "changes_since": "changes-since"}, + "changes_since": "changes-since", + "limit": "limit", + "marker": "marker"}, sot._query_mapping._mapping) def test_make_basic(self): diff --git a/openstack/tests/unit/compute/v2/test_server.py b/openstack/tests/unit/compute/v2/test_server.py index 898ee65f..c38853f5 100644 --- a/openstack/tests/unit/compute/v2/test_server.py +++ b/openstack/tests/unit/compute/v2/test_server.py @@ -83,7 +83,9 @@ class TestServer(testtools.TestCase): "status": "status", "host": "host", "all_tenants": "all_tenants", - "changes_since": "changes-since"}, + "changes_since": "changes-since", + "limit": "limit", + "marker": "marker"}, sot._query_mapping._mapping) def test_make_it(self): diff --git a/openstack/tests/unit/compute/v2/test_server_group.py b/openstack/tests/unit/compute/v2/test_server_group.py index ea6d983d..3fabbfc1 100644 --- a/openstack/tests/unit/compute/v2/test_server_group.py +++ b/openstack/tests/unit/compute/v2/test_server_group.py @@ -37,7 +37,8 @@ class TestServerGroup(testtools.TestCase): self.assertTrue(sot.allow_delete) self.assertTrue(sot.allow_list) - self.assertDictEqual({"all_projects": "all_projects"}, + self.assertDictEqual({"all_projects": "all_projects", + "limit": "limit", "marker": "marker"}, sot._query_mapping._mapping) def test_make_it(self): diff --git a/openstack/tests/unit/key_manager/v1/test_secret.py b/openstack/tests/unit/key_manager/v1/test_secret.py index 14ff9fa0..9e103ecb 100644 --- a/openstack/tests/unit/key_manager/v1/test_secret.py +++ b/openstack/tests/unit/key_manager/v1/test_secret.py @@ -58,7 +58,9 @@ class TestSecret(testtools.TestCase): "updated": "updated", "expiration": "expiration", "sort": "sort", - "algorithm": "alg"}, + "algorithm": "alg", + "limit": "limit", + "marker": "marker"}, sot._query_mapping._mapping) def test_make_it(self): diff --git a/openstack/tests/unit/test_resource2.py b/openstack/tests/unit/test_resource2.py index 4c23396f..147ad4ff 100644 --- a/openstack/tests/unit/test_resource2.py +++ b/openstack/tests/unit/test_resource2.py @@ -350,7 +350,10 @@ class TestQueryParameters(base.TestCase): sot = resource2.QueryParameters(location, **mapping) - self.assertEqual({"location": "location", "first_name": "first-name"}, + self.assertEqual({"location": "location", + "first_name": "first-name", + "limit": "limit", + "marker": "marker"}, sot._mapping) def test_transpose_unmapped(self):