make req_ref doesn't require id

The test_update and test_create methods of
keystoneclient.tests.v3.utils.CrudTests are very strange: they
require req_ref parameter to contain 'id' attribute, however,
they just remove 'id' from req_ref then.

Change-Id: Ic577546ef03611b2a19f8be661660ad8bd0d8c06
This commit is contained in:
wanghong
2015-01-20 19:00:07 +08:00
parent 0eab8ff920
commit d1bad7674b
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
req_ref = self.new_ref()
api_ref = self._ref_data_not_blob(req_ref)
req_ref.pop('id')
self.test_create(api_ref, req_ref)
def test_update_data_not_blob(self):

View File

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

View File

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

View File

@@ -55,6 +55,7 @@ class TrustTests(utils.TestCase, utils.CrudTests):
ref['trustee_user_id'] = uuid.uuid4().hex
ref['impersonation'] = False
req_ref = ref.copy()
req_ref.pop('id')
# Note the TrustManager takes a list of role_names, and converts
# 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(
'2013-03-04T12:00:01.000000Z')
req_ref = ref.copy()
req_ref.pop('id')
# Note the TrustManager takes a datetime.datetime object for
# 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['impersonation'] = True
req_ref = ref.copy()
req_ref.pop('id')
ref['role_names'] = ['atestrole']
req_ref['roles'] = [{'name': 'atestrole'}]
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
# conversion before doing the request (e.g. converting
# from datetime object to timestamp string)
req_ref = (req_ref or ref).copy()
req_ref.pop('id')
if req_ref:
req_ref = req_ref.copy()
else:
req_ref = ref.copy()
req_ref.pop('id')
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
# conversion before doing the request (e.g. converting
# from datetime object to timestamp string)
req_ref = (req_ref or ref).copy()
req_ref.pop('id')
if req_ref:
req_ref = req_ref.copy()
else:
req_ref = ref.copy()
req_ref.pop('id')
returned = self.manager.update(ref['id'], **parameterize(req_ref))
self.assertIsInstance(returned, self.model)