Merge "Fix PEP8 E126 and E202 errors"

This commit is contained in:
Jenkins 2014-06-27 21:41:34 +00:00 committed by Gerrit Code Review
commit ddf0c16a10
4 changed files with 359 additions and 319 deletions

View File

@ -32,30 +32,33 @@ class TestConsumerCreate(TestOAuth1):
super(TestConsumerCreate, self).setUp()
self.consumers_mock.create.return_value = fakes.FakeResource(
None, copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
loaded=True)
None,
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
loaded=True,
)
self.cmd = consumer.CreateConsumer(self.app, None)
def test_create_consumer(self):
arglist = [
'--description', identity_fakes.consumer_description
'--description', identity_fakes.consumer_description,
]
verifylist = [
('description', identity_fakes.consumer_description)
('description', identity_fakes.consumer_description),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.consumers_mock.create.assert_called_with(
identity_fakes.consumer_description)
identity_fakes.consumer_description,
)
collist = ('description', 'id', 'secret')
self.assertEqual(columns, collist)
datalist = (
identity_fakes.consumer_description,
identity_fakes.consumer_id,
identity_fakes.consumer_secret
identity_fakes.consumer_secret,
)
self.assertEqual(data, datalist)
@ -69,17 +72,18 @@ class TestConsumerDelete(TestOAuth1):
self.consumers_mock.get.return_value = fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
loaded=True)
loaded=True,
)
self.consumers_mock.delete.return_value = None
self.cmd = consumer.DeleteConsumer(self.app, None)
def test_delete_consumer(self):
arglist = [
identity_fakes.consumer_id
identity_fakes.consumer_id,
]
verifylist = [
('consumer', identity_fakes.consumer_id)
('consumer', identity_fakes.consumer_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -125,7 +129,7 @@ class TestConsumerList(TestOAuth1):
self.assertEqual(columns, collist)
datalist = ((
identity_fakes.consumer_id,
identity_fakes.consumer_description
identity_fakes.consumer_description,
), )
self.assertEqual(tuple(data), datalist)
@ -138,29 +142,33 @@ class TestConsumerShow(TestOAuth1):
consumer_no_secret = copy.deepcopy(identity_fakes.OAUTH_CONSUMER)
del consumer_no_secret['secret']
self.consumers_mock.get.return_value = fakes.FakeResource(
None, consumer_no_secret, loaded=True)
None,
consumer_no_secret,
loaded=True,
)
# Get the command object to test
self.cmd = consumer.ShowConsumer(self.app, None)
def test_consumer_show(self):
arglist = [
identity_fakes.consumer_id
identity_fakes.consumer_id,
]
verifylist = [
('consumer', identity_fakes.consumer_id)
('consumer', identity_fakes.consumer_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.consumers_mock.get.assert_called_with(
identity_fakes.consumer_id)
identity_fakes.consumer_id,
)
collist = ('description', 'id' )
collist = ('description', 'id')
self.assertEqual(columns, collist)
datalist = (
identity_fakes.consumer_description,
identity_fakes.consumer_id
identity_fakes.consumer_id,
)
self.assertEqual(data, datalist)
@ -171,12 +179,18 @@ class TestConsumerSet(TestOAuth1):
super(TestConsumerSet, self).setUp()
self.consumers_mock.get.return_value = fakes.FakeResource(
None, copy.deepcopy(identity_fakes.OAUTH_CONSUMER), loaded=True)
None,
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
loaded=True,
)
consumer_updated = copy.deepcopy(identity_fakes.OAUTH_CONSUMER)
consumer_updated['description'] = "consumer new description"
self.consumers_mock.update.return_value = fakes.FakeResource(
None, consumer_updated, loaded=True)
None,
consumer_updated,
loaded=True,
)
self.cmd = consumer.SetConsumer(self.app, None)
@ -185,11 +199,11 @@ class TestConsumerSet(TestOAuth1):
arglist = [
'--description', new_description,
identity_fakes.consumer_id
identity_fakes.consumer_id,
]
verifylist = [
('description', new_description),
('consumer', identity_fakes.consumer_id)
('consumer', identity_fakes.consumer_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.run(parsed_args)
@ -197,4 +211,6 @@ class TestConsumerSet(TestOAuth1):
kwargs = {'description': new_description}
self.consumers_mock.update.assert_called_with(
identity_fakes.consumer_id, **kwargs)
identity_fakes.consumer_id,
**kwargs
)

View File

@ -39,18 +39,20 @@ class TestIdentityProviderCreate(TestIdentityProvider):
fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
loaded=True
loaded=True,
)
self.cmd = identity_provider.CreateIdentityProvider(
self.app, None)
self.app,
None,
)
def test_create_identity_provider_no_options(self):
arglist = [
identity_fakes.idp_id
identity_fakes.idp_id,
]
verifylist = [
('identity_provider_id', identity_fakes.idp_id)
('identity_provider_id', identity_fakes.idp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@ -62,7 +64,9 @@ class TestIdentityProviderCreate(TestIdentityProvider):
}
self.identity_providers_mock.create.assert_called_with(
identity_fakes.idp_id, **kwargs)
identity_fakes.idp_id,
**kwargs
)
collist = ('description', 'enabled', 'id')
self.assertEqual(columns, collist)
@ -74,11 +78,13 @@ class TestIdentityProviderCreate(TestIdentityProvider):
self.assertEqual(data, datalist)
def test_create_identity_provider_description(self):
arglist = ['--description', identity_fakes.idp_description,
identity_fakes.idp_id]
arglist = [
'--description', identity_fakes.idp_description,
identity_fakes.idp_id,
]
verifylist = [
('identity_provider_id', identity_fakes.idp_id),
('description', identity_fakes.idp_description)
('description', identity_fakes.idp_description),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@ -90,12 +96,16 @@ class TestIdentityProviderCreate(TestIdentityProvider):
}
self.identity_providers_mock.create.assert_called_with(
identity_fakes.idp_id, **kwargs)
identity_fakes.idp_id,
**kwargs
)
collist = ('description', 'enabled', 'id')
self.assertEqual(columns, collist)
datalist = (
identity_fakes.idp_description, True, identity_fakes.idp_id,
identity_fakes.idp_description,
True,
identity_fakes.idp_id,
)
self.assertEqual(data, datalist)
@ -110,13 +120,14 @@ class TestIdentityProviderCreate(TestIdentityProvider):
fakes.FakeResource(
None,
IDENTITY_PROVIDER,
loaded=True
loaded=True,
)
arglist = ['--disable',
identity_fakes.idp_id]
arglist = [
'--disable',
identity_fakes.idp_id,
]
verifylist = [
('identity_provider_id', identity_fakes.idp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@ -124,11 +135,13 @@ class TestIdentityProviderCreate(TestIdentityProvider):
# Set expected values
kwargs = {
'enabled': False,
'description': None
'description': None,
}
self.identity_providers_mock.create.assert_called_with(
identity_fakes.idp_id, **kwargs)
identity_fakes.idp_id,
**kwargs
)
collist = ('description', 'enabled', 'id')
self.assertEqual(columns, collist)
@ -149,18 +162,18 @@ class TestIdentityProviderDelete(TestIdentityProvider):
self.identity_providers_mock.get.return_value = fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
loaded=True)
loaded=True,
)
self.identity_providers_mock.delete.return_value = None
self.cmd = identity_provider.DeleteIdentityProvider(
self.app, None)
self.cmd = identity_provider.DeleteIdentityProvider(self.app, None)
def test_delete_identity_provider(self):
arglist = [
identity_fakes.idp_id
identity_fakes.idp_id,
]
verifylist = [
('identity_provider', identity_fakes.idp_id)
('identity_provider', identity_fakes.idp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
@ -205,8 +218,7 @@ class TestIdentityProviderList(TestIdentityProvider):
datalist = ((
identity_fakes.idp_id,
True,
identity_fakes.idp_description
identity_fakes.idp_description,
), )
self.assertEqual(tuple(data), datalist)
@ -219,7 +231,7 @@ class TestIdentityProviderShow(TestIdentityProvider):
self.identity_providers_mock.get.return_value = fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
loaded=True
loaded=True,
)
# Get the command object to test
@ -227,24 +239,25 @@ class TestIdentityProviderShow(TestIdentityProvider):
def test_identity_provider_show(self):
arglist = [
identity_fakes.idp_id
identity_fakes.idp_id,
]
verifylist = [
('identity_provider', identity_fakes.idp_id)
('identity_provider', identity_fakes.idp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.identity_providers_mock.get.assert_called_with(
identity_fakes.idp_id)
identity_fakes.idp_id,
)
collist = ('description', 'enabled', 'id' )
collist = ('description', 'enabled', 'id')
self.assertEqual(columns, collist)
datalist = (
identity_fakes.idp_description,
True,
identity_fakes.idp_id
identity_fakes.idp_id,
)
self.assertEqual(data, datalist)
@ -259,7 +272,6 @@ class TestIdentityProviderSet(TestIdentityProvider):
"""Disable Identity Provider
Set Identity Provider's ``enabled`` attribute to False.
"""
def prepare(self):
"""Prepare fake return objects before the test is executed"""
@ -274,23 +286,27 @@ class TestIdentityProviderSet(TestIdentityProvider):
prepare(self)
arglist = [
'--disable', identity_fakes.idp_id
'--disable', identity_fakes.idp_id,
]
verifylist = [
('identity_provider', identity_fakes.idp_id),
('enable', False),
('disable', True)
('disable', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.identity_providers_mock.update.assert_called_with(
identity_fakes.idp_id, enabled=False)
collist = ('description', 'enabled', 'id' )
identity_fakes.idp_id,
enabled=False,
)
collist = ('description', 'enabled', 'id')
self.assertEqual(columns, collist)
datalist = (
identity_fakes.idp_description,
False,
identity_fakes.idp_id
identity_fakes.idp_id,
)
self.assertEqual(datalist, data)
@ -298,7 +314,6 @@ class TestIdentityProviderSet(TestIdentityProvider):
"""Enable Identity Provider.
Set Identity Provider's ``enabled`` attribute to True.
"""
def prepare(self):
"""Prepare fake return objects before the test is executed"""
@ -311,24 +326,24 @@ class TestIdentityProviderSet(TestIdentityProvider):
prepare(self)
arglist = [
'--enable', identity_fakes.idp_id
'--enable', identity_fakes.idp_id,
]
verifylist = [
('identity_provider', identity_fakes.idp_id),
('enable', True),
('disable', False)
('disable', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.identity_providers_mock.update.assert_called_with(
identity_fakes.idp_id, enabled=True)
collist = ('description', 'enabled', 'id' )
collist = ('description', 'enabled', 'id')
self.assertEqual(columns, collist)
datalist = (
identity_fakes.idp_description,
True,
identity_fakes.idp_id
identity_fakes.idp_id,
)
self.assertEqual(data, datalist)
@ -345,18 +360,18 @@ class TestIdentityProviderSet(TestIdentityProvider):
resources = fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
loaded=True
loaded=True,
)
self.identity_providers_mock.update.return_value = resources
prepare(self)
arglist = [
identity_fakes.idp_id
identity_fakes.idp_id,
]
verifylist = [
('identity_provider', identity_fakes.idp_id),
('enable', False),
('disable', False)
('disable', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)

View File

@ -34,8 +34,10 @@ class TestRequestTokenCreate(TestOAuth1):
super(TestRequestTokenCreate, self).setUp()
self.request_tokens_mock.create.return_value = fakes.FakeResource(
None, copy.deepcopy(identity_fakes.OAUTH_REQUEST_TOKEN),
loaded=True)
None,
copy.deepcopy(identity_fakes.OAUTH_REQUEST_TOKEN),
loaded=True,
)
self.cmd = token.CreateRequestToken(self.app, None)
@ -43,12 +45,12 @@ class TestRequestTokenCreate(TestOAuth1):
arglist = [
'--consumer-key', identity_fakes.consumer_id,
'--consumer-secret', identity_fakes.consumer_secret,
'--project-id', identity_fakes.project_id
'--project-id', identity_fakes.project_id,
]
verifylist = [
('consumer_key', identity_fakes.consumer_id),
('consumer_secret', identity_fakes.consumer_secret),
('project_id', identity_fakes.project_id)
('project_id', identity_fakes.project_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@ -56,7 +58,8 @@ class TestRequestTokenCreate(TestOAuth1):
self.request_tokens_mock.create.assert_called_with(
identity_fakes.consumer_id,
identity_fakes.consumer_secret,
identity_fakes.project_id)
identity_fakes.project_id,
)
collist = ('expires', 'id', 'key', 'secret')
self.assertEqual(columns, collist)
@ -64,7 +67,7 @@ class TestRequestTokenCreate(TestOAuth1):
identity_fakes.request_token_expires,
identity_fakes.request_token_id,
identity_fakes.request_token_id,
identity_fakes.request_token_secret
identity_fakes.request_token_secret,
)
self.assertEqual(data, datalist)
@ -76,26 +79,29 @@ class TestRequestTokenAuthorize(TestOAuth1):
self.request_tokens_mock.authorize.return_value = \
fakes.FakeResource(
None, copy.deepcopy(identity_fakes.OAUTH_VERIFIER),
loaded=True)
None,
copy.deepcopy(identity_fakes.OAUTH_VERIFIER),
loaded=True,
)
self.cmd = token.AuthorizeRequestToken(self.app, None)
def test_authorize_request_tokens(self):
arglist = [
'--request-key', identity_fakes.request_token_id,
'--role-ids', identity_fakes.role_id
'--role-ids', identity_fakes.role_id,
]
verifylist = [
('request_key', identity_fakes.request_token_id),
('role_ids', identity_fakes.role_id)
('role_ids', identity_fakes.role_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.request_tokens_mock.authorize.assert_called_with(
identity_fakes.request_token_id,
[identity_fakes.role_id])
[identity_fakes.role_id],
)
collist = ('oauth_verifier',)
self.assertEqual(columns, collist)
@ -111,8 +117,10 @@ class TestAccessTokenCreate(TestOAuth1):
super(TestAccessTokenCreate, self).setUp()
self.access_tokens_mock.create.return_value = fakes.FakeResource(
None, copy.deepcopy(identity_fakes.OAUTH_ACCESS_TOKEN),
loaded=True)
None,
copy.deepcopy(identity_fakes.OAUTH_ACCESS_TOKEN),
loaded=True,
)
self.cmd = token.CreateAccessToken(self.app, None)
@ -122,14 +130,14 @@ class TestAccessTokenCreate(TestOAuth1):
'--consumer-secret', identity_fakes.consumer_secret,
'--request-key', identity_fakes.request_token_id,
'--request-secret', identity_fakes.request_token_secret,
'--verifier', identity_fakes.oauth_verifier_pin
'--verifier', identity_fakes.oauth_verifier_pin,
]
verifylist = [
('consumer_key', identity_fakes.consumer_id),
('consumer_secret', identity_fakes.consumer_secret),
('request_key', identity_fakes.request_token_id),
('request_secret', identity_fakes.request_token_secret),
('verifier', identity_fakes.oauth_verifier_pin)
('verifier', identity_fakes.oauth_verifier_pin),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@ -139,7 +147,8 @@ class TestAccessTokenCreate(TestOAuth1):
identity_fakes.consumer_secret,
identity_fakes.request_token_id,
identity_fakes.request_token_secret,
identity_fakes.oauth_verifier_pin)
identity_fakes.oauth_verifier_pin,
)
collist = ('expires', 'id', 'key', 'secret')
self.assertEqual(columns, collist)
@ -147,6 +156,6 @@ class TestAccessTokenCreate(TestOAuth1):
identity_fakes.access_token_expires,
identity_fakes.access_token_id,
identity_fakes.access_token_id,
identity_fakes.access_token_secret
identity_fakes.access_token_secret,
)
self.assertEqual(data, datalist)

View File

@ -28,6 +28,6 @@ commands=
python setup.py build_sphinx
[flake8]
ignore = E126,E202,W602,H302,H402,H305,H307,H904
ignore = H302,H305,H307,H402,H904
show-source = True
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools