Merge "Provide consistency for Wrapper classes"

This commit is contained in:
Jenkins
2016-02-23 22:03:49 +00:00
committed by Gerrit Code Review
3 changed files with 6 additions and 6 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)