identity: use set() for valid_options

That looks cleaner as the order is not important.

Change-Id: I4301b6b98e4f0697c7b5c6e1a9b85689b18587d0
This commit is contained in:
Julien Danjou
2015-03-03 16:26:28 +01:00
parent a45bd97d46
commit c6dd7b6cb3
4 changed files with 15 additions and 15 deletions

View File

@@ -39,10 +39,10 @@ from openstack import exceptions
class Auth(base.BaseIdentityPlugin): class Auth(base.BaseIdentityPlugin):
#: Valid options for this plugin #: Valid options for this plugin
valid_options = list(set(v2.Password.valid_options + valid_options = set(list(v3.Password.valid_options)
v2.Token.valid_options + + list(v3.Token.valid_options)
v3.Password.valid_options + + list(v2.Password.valid_options)
v3.Token.valid_options)) + list(v2.Token.valid_options))
def __init__(self, auth_url=None, **auth_args): def __init__(self, auth_url=None, **auth_args):
"""Construct an Identity Authentication Plugin. """Construct an Identity Authentication Plugin.

View File

@@ -112,7 +112,7 @@ _NOT_PASSED = object()
class Password(Auth): class Password(Auth):
#: Valid options for Password plugin #: Valid options for Password plugin
valid_options = [ valid_options = {
'access_info', 'access_info',
'auth_url', 'auth_url',
'username', 'username',
@@ -124,7 +124,7 @@ class Password(Auth):
'tenant_id', 'tenant_id',
'reauthenticate', 'reauthenticate',
'trust_id', 'trust_id',
] }
def __init__(self, auth_url, username=_NOT_PASSED, password=None, def __init__(self, auth_url, username=_NOT_PASSED, password=None,
user_id=_NOT_PASSED, **kwargs): user_id=_NOT_PASSED, **kwargs):
@@ -167,7 +167,7 @@ class Password(Auth):
class Token(Auth): class Token(Auth):
#: Valid options for this plugin #: Valid options for this plugin
valid_options = [ valid_options = {
'access_info', 'access_info',
'auth_url', 'auth_url',
'project_id', 'project_id',
@@ -177,7 +177,7 @@ class Token(Auth):
'reauthenticate', 'reauthenticate',
'token', 'token',
'trust_id', 'trust_id',
] }
def __init__(self, auth_url, token, **kwargs): def __init__(self, auth_url, token, **kwargs):
"""A plugin for authenticating with an existing token. """A plugin for authenticating with an existing token.

View File

@@ -250,7 +250,7 @@ class PasswordMethod(AuthMethod):
class Password(AuthConstructor): class Password(AuthConstructor):
#: Valid options for this plugin #: Valid options for this plugin
valid_options = [ valid_options = {
'access_info', 'access_info',
'auth_url', 'auth_url',
'domain_id', 'domain_id',
@@ -266,7 +266,7 @@ class Password(AuthConstructor):
'user_domain_name', 'user_domain_name',
'user_id', 'user_id',
'username', 'username',
] }
_auth_method_class = PasswordMethod _auth_method_class = PasswordMethod
@@ -292,7 +292,7 @@ class TokenMethod(AuthMethod):
class Token(AuthConstructor): class Token(AuthConstructor):
#: Valid options for this plugin #: Valid options for this plugin
valid_options = [ valid_options = {
'access_info', 'access_info',
'auth_url', 'auth_url',
'domain_id', 'domain_id',
@@ -306,7 +306,7 @@ class Token(AuthConstructor):
'trust_id', 'trust_id',
'user_domain_id', 'user_domain_id',
'user_domain_name', 'user_domain_name',
] }
_auth_method_class = TokenMethod _auth_method_class = TokenMethod

View File

@@ -20,7 +20,7 @@ from openstack.tests.auth import common
class TestDiscoverableAuth(testtools.TestCase): class TestDiscoverableAuth(testtools.TestCase):
def test_valid_options(self): def test_valid_options(self):
expected = [ expected = {
'access_info', 'access_info',
'auth_url', 'auth_url',
'domain_id', 'domain_id',
@@ -39,8 +39,8 @@ class TestDiscoverableAuth(testtools.TestCase):
'user_domain_name', 'user_domain_name',
'user_id', 'user_id',
'username', 'username',
] }
self.assertEqual(expected, sorted(discoverable.Auth.valid_options)) self.assertEqual(expected, discoverable.Auth.valid_options)
def test_create2(self): def test_create2(self):
auth_args = { auth_args = {