Merge "make req_ref doesn't require id"

This commit is contained in:
Jenkins
2015-02-02 01:04:37 +00:00
committed by Gerrit Code Review
5 changed files with 18 additions and 10 deletions

View File

@@ -44,6 +44,7 @@ class CredentialTests(utils.TestCase, utils.CrudTests):
# which should be translated into "blob" at the API call level # which should be translated into "blob" at the API call level
req_ref = self.new_ref() req_ref = self.new_ref()
api_ref = self._ref_data_not_blob(req_ref) api_ref = self._ref_data_not_blob(req_ref)
req_ref.pop('id')
self.test_create(api_ref, req_ref) self.test_create(api_ref, req_ref)
def test_update_data_not_blob(self): def test_update_data_not_blob(self):

View File

@@ -43,6 +43,5 @@ class DomainTests(utils.TestCase, utils.CrudTests):
enabled=False) enabled=False)
def test_update_enabled_defaults_to_none(self): def test_update_enabled_defaults_to_none(self):
req_ref = self.new_ref() super(DomainTests, self).test_update(
del req_ref['enabled'] req_ref={'name': uuid.uuid4().hex})
super(DomainTests, self).test_update(req_ref=req_ref)

View File

@@ -33,6 +33,5 @@ class RegionTests(utils.TestCase, utils.CrudTests):
return kwargs return kwargs
def test_update_enabled_defaults_to_none(self): def test_update_enabled_defaults_to_none(self):
req_ref = self.new_ref() super(RegionTests, self).test_update(
del req_ref['enabled'] req_ref={'description': uuid.uuid4().hex})
super(RegionTests, self).test_update(req_ref=req_ref)

View File

@@ -55,6 +55,7 @@ class TrustTests(utils.TestCase, utils.CrudTests):
ref['trustee_user_id'] = uuid.uuid4().hex ref['trustee_user_id'] = uuid.uuid4().hex
ref['impersonation'] = False ref['impersonation'] = False
req_ref = ref.copy() req_ref = ref.copy()
req_ref.pop('id')
# Note the TrustManager takes a list of role_names, and converts # Note the TrustManager takes a list of role_names, and converts
# internally to the slightly odd list-of-dict API format, so we # internally to the slightly odd list-of-dict API format, so we
@@ -71,6 +72,7 @@ class TrustTests(utils.TestCase, utils.CrudTests):
ref['expires_at'] = timeutils.parse_isotime( ref['expires_at'] = timeutils.parse_isotime(
'2013-03-04T12:00:01.000000Z') '2013-03-04T12:00:01.000000Z')
req_ref = ref.copy() req_ref = ref.copy()
req_ref.pop('id')
# Note the TrustManager takes a datetime.datetime object for # Note the TrustManager takes a datetime.datetime object for
# expires_at, and converts it internally into an iso format datestamp # expires_at, and converts it internally into an iso format datestamp
@@ -90,6 +92,7 @@ class TrustTests(utils.TestCase, utils.CrudTests):
ref['trustee_user_id'] = uuid.uuid4().hex ref['trustee_user_id'] = uuid.uuid4().hex
ref['impersonation'] = True ref['impersonation'] = True
req_ref = ref.copy() req_ref = ref.copy()
req_ref.pop('id')
ref['role_names'] = ['atestrole'] ref['role_names'] = ['atestrole']
req_ref['roles'] = [{'name': 'atestrole'}] req_ref['roles'] = [{'name': 'atestrole'}]
super(TrustTests, self).test_create(ref=ref, req_ref=req_ref) super(TrustTests, self).test_create(ref=ref, req_ref=req_ref)

View File

@@ -202,8 +202,11 @@ class CrudTests(object):
# signature for the request when the manager does some # signature for the request when the manager does some
# conversion before doing the request (e.g. converting # conversion before doing the request (e.g. converting
# from datetime object to timestamp string) # from datetime object to timestamp string)
req_ref = (req_ref or ref).copy() if req_ref:
req_ref.pop('id') req_ref = req_ref.copy()
else:
req_ref = ref.copy()
req_ref.pop('id')
self.stub_entity('POST', entity=req_ref, status_code=201) self.stub_entity('POST', entity=req_ref, status_code=201)
@@ -304,8 +307,11 @@ class CrudTests(object):
# signature for the request when the manager does some # signature for the request when the manager does some
# conversion before doing the request (e.g. converting # conversion before doing the request (e.g. converting
# from datetime object to timestamp string) # from datetime object to timestamp string)
req_ref = (req_ref or ref).copy() if req_ref:
req_ref.pop('id') req_ref = req_ref.copy()
else:
req_ref = ref.copy()
req_ref.pop('id')
returned = self.manager.update(ref['id'], **parameterize(req_ref)) returned = self.manager.update(ref['id'], **parameterize(req_ref))
self.assertIsInstance(returned, self.model) self.assertIsInstance(returned, self.model)