summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Agrawal <ankit11.agrawal@nttdata.com>2016-02-15 22:59:05 -0800
committerAnkit Agrawal <ankit11.agrawal@nttdata.com>2016-02-15 23:41:31 -0800
commitb2fc77f731c9cdb02efaa942f140ee7fd134ffac (patch)
treed46f82972671a40491ce0a2e8f622107c3bf75be
parentbdeb22da28a679064023e49724e341877842e967 (diff)
downloadpython-cinderclient-b2fc77f731c9cdb02efaa942f140ee7fd134ffac.tar.gz
Provide consistency for Wrapper classes
Updated TupleWithMeta class to make it consistent with other Meta classes in order to avoid confusion. Also made provision to call TupleWithMeta with a tuple containing one or more elements. For more details on how request_id will be returned to the caller, please refer to the approved blueprint [1] discussed with the cross-project team. [1] http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html Change-Id: I5a79a4ed8cb4dc83ea3b64499df191750462100d Partial-Implements: blueprint return-request-id-to-caller
-rw-r--r--cinderclient/base.py2
-rw-r--r--cinderclient/openstack/common/apiclient/base.py6
-rw-r--r--cinderclient/tests/unit/test_base.py4
3 files changed, 6 insertions, 6 deletions
diff --git a/cinderclient/base.py b/cinderclient/base.py
index 36e7df8..78c6fd2 100644
--- a/cinderclient/base.py
+++ b/cinderclient/base.py
@@ -307,7 +307,7 @@ class Manager(common_base.HookableMixin):
def _delete(self, url):
resp, body = self.api.client.delete(url)
- return common_base.TupleWithMeta(resp, body)
+ return common_base.TupleWithMeta((resp, body), resp)
def _update(self, url, body, response_key=None, **kwargs):
self.run_hooks('modify_body_for_update', body, **kwargs)
diff --git a/cinderclient/openstack/common/apiclient/base.py b/cinderclient/openstack/common/apiclient/base.py
index abfcdfe..3645f68 100644
--- a/cinderclient/openstack/common/apiclient/base.py
+++ b/cinderclient/openstack/common/apiclient/base.py
@@ -551,9 +551,9 @@ class DictWithMeta(dict, RequestIdMixin):
class TupleWithMeta(tuple, RequestIdMixin):
- def __new__(cls, resp, values):
- return super(TupleWithMeta, cls).__new__(cls, (resp, values))
+ def __new__(cls, values, resp):
+ return super(TupleWithMeta, cls).__new__(cls, values)
- def __init__(self, resp, values):
+ def __init__(self, values, resp):
self.setup()
self.append_request_ids(resp)
diff --git a/cinderclient/tests/unit/test_base.py b/cinderclient/tests/unit/test_base.py
index 7d329de..67265a7 100644
--- a/cinderclient/tests/unit/test_base.py
+++ b/cinderclient/tests/unit/test_base.py
@@ -106,8 +106,8 @@ class DictWithMetaTest(utils.TestCase):
class TupleWithMetaTest(utils.TestCase):
def test_tuple_with_meta(self):
resp = create_response_obj_with_header()
- obj = common_base.TupleWithMeta(resp, None)
- self.assertIsInstance(obj, tuple)
+ obj = common_base.TupleWithMeta((), resp)
+ self.assertEqual((), obj)
# Check request_ids attribute is added to obj
self.assertTrue(hasattr(obj, 'request_ids'))
self.assertEqual([REQUEST_ID], obj.request_ids)