Merge "Let KeystoneCredentials.to_dict() method to return a dictionary."
This commit is contained in:
commit
4989670e21
@ -60,10 +60,9 @@ class KeystoneCredentials(collections.namedtuple(
|
|||||||
'trust_id'])):
|
'trust_id'])):
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return collections.OrderedDict(
|
return {k: v
|
||||||
(k, v)
|
for k, v in self._asdict().items()
|
||||||
for k, v in self._asdict().items()
|
if v is not None}
|
||||||
if v is not None)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
params = self.to_dict()
|
params = self.to_dict()
|
||||||
@ -71,7 +70,7 @@ class KeystoneCredentials(collections.namedtuple(
|
|||||||
params['password'] = '***'
|
params['password'] = '***'
|
||||||
return 'keystone_credentials({!s})'.format(
|
return 'keystone_credentials({!s})'.format(
|
||||||
", ".join("{!s}={!r}".format(k, v)
|
", ".join("{!s}={!r}".format(k, v)
|
||||||
for k, v in params.items()))
|
for k, v in sorted(params.items())))
|
||||||
|
|
||||||
required_params = ('auth_url', 'username', 'password', 'project_name')
|
required_params = ('auth_url', 'username', 'password', 'project_name')
|
||||||
|
|
||||||
|
@ -77,9 +77,12 @@ class KeystoneCredentialsTest(openstack.OpenstackTest):
|
|||||||
credentials.validate()
|
credentials.validate()
|
||||||
self.assertEqual(V2_PARAMS, credentials.to_dict())
|
self.assertEqual(V2_PARAMS, credentials.to_dict())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"keystone_credentials(api_version=2, "
|
"keystone_credentials("
|
||||||
"auth_url='http://10.0.0.1:5678/v2.0', username='demo', "
|
"api_version=2, "
|
||||||
"password='***', project_name='demo')",
|
"auth_url='http://10.0.0.1:5678/v2.0', "
|
||||||
|
"password='***', "
|
||||||
|
"project_name='demo', "
|
||||||
|
"username='demo')",
|
||||||
repr(credentials))
|
repr(credentials))
|
||||||
|
|
||||||
def test_validate_from_params_v3(self):
|
def test_validate_from_params_v3(self):
|
||||||
@ -87,11 +90,14 @@ class KeystoneCredentialsTest(openstack.OpenstackTest):
|
|||||||
credentials.validate()
|
credentials.validate()
|
||||||
self.assertEqual(V3_PARAMS, credentials.to_dict())
|
self.assertEqual(V3_PARAMS, credentials.to_dict())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"keystone_credentials(api_version=3, "
|
"keystone_credentials("
|
||||||
"auth_url='http://10.0.0.1:5678/v3', username='demo', "
|
"api_version=3, "
|
||||||
"password='***', project_name='demo', "
|
"auth_url='http://10.0.0.1:5678/v3', "
|
||||||
|
"password='***', "
|
||||||
|
"project_domain_name='Default', "
|
||||||
|
"project_name='demo', "
|
||||||
"user_domain_name='Default', "
|
"user_domain_name='Default', "
|
||||||
"project_domain_name='Default')",
|
"username='demo')",
|
||||||
repr(credentials))
|
repr(credentials))
|
||||||
|
|
||||||
def test_validate_without_auth_url(self):
|
def test_validate_without_auth_url(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user