Switch to ignoring pep W503
Change-Id: I3fe7b6f33fa327a9584bbad3c695032bc0a3e54a
This commit is contained in:
parent
496be1b077
commit
d4ab292a6a
@ -109,10 +109,9 @@ class NewProjectAction(BaseAction, ProjectMixin, UserMixin):
|
|||||||
# put user_id into action cache:
|
# put user_id into action cache:
|
||||||
self.action.task.cache['user_id'] = user.id
|
self.action.task.cache['user_id'] = user.id
|
||||||
self.set_cache('user_id', user.id)
|
self.set_cache('user_id', user.id)
|
||||||
self.add_note(("Existing user '%s' attached to project %s" +
|
self.add_note(
|
||||||
" with roles: %s")
|
"Existing user '%s' attached to project %s with roles: %s"
|
||||||
% (user.name, project_id,
|
% (user.name, project_id, default_roles))
|
||||||
default_roles))
|
|
||||||
|
|
||||||
def _submit(self, token_data):
|
def _submit(self, token_data):
|
||||||
"""
|
"""
|
||||||
@ -221,9 +220,9 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||||||
self.add_note("Project already created.")
|
self.add_note("Project already created.")
|
||||||
else:
|
else:
|
||||||
self.action.valid = (
|
self.action.valid = (
|
||||||
self._validate_domain_id() and
|
self._validate_domain_id()
|
||||||
self._validate_parent_project() and
|
and self._validate_parent_project()
|
||||||
self._validate_project_absent())
|
and self._validate_project_absent())
|
||||||
self.action.save()
|
self.action.save()
|
||||||
|
|
||||||
if not self.valid:
|
if not self.valid:
|
||||||
@ -302,10 +301,9 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
self.set_cache('roles_granted', True)
|
self.set_cache('roles_granted', True)
|
||||||
self.add_note(("Existing user '%s' setup on project %s" +
|
self.add_note(
|
||||||
" with roles: %s")
|
"Existing user '%s' setup on project %s with roles: %s"
|
||||||
% (self.username, project_id,
|
% (self.username, project_id, default_roles))
|
||||||
default_roles))
|
|
||||||
elif self.action.state == "disabled":
|
elif self.action.state == "disabled":
|
||||||
user_id = self.get_cache('user_id')
|
user_id = self.get_cache('user_id')
|
||||||
if not user_id:
|
if not user_id:
|
||||||
@ -349,10 +347,9 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||||||
raise
|
raise
|
||||||
self.set_cache('roles_granted', True)
|
self.set_cache('roles_granted', True)
|
||||||
|
|
||||||
self.add_note(("Existing user '%s' setup on project %s" +
|
self.add_note(
|
||||||
" with roles: %s")
|
"Existing user '%s' setup on project %s with roles: %s"
|
||||||
% (self.username, project_id,
|
% (self.username, project_id, default_roles))
|
||||||
default_roles))
|
|
||||||
|
|
||||||
def _submit(self, token_data):
|
def _submit(self, token_data):
|
||||||
"""
|
"""
|
||||||
|
@ -31,8 +31,7 @@ from adjutant.common.tests.fake_clients import (
|
|||||||
@mock.patch('adjutant.common.user_store.IdentityManager',
|
@mock.patch('adjutant.common.user_store.IdentityManager',
|
||||||
FakeManager)
|
FakeManager)
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'adjutant.actions.v1.resources.' +
|
'adjutant.actions.v1.resources.openstack_clients.get_neutronclient',
|
||||||
'openstack_clients.get_neutronclient',
|
|
||||||
get_fake_neutron)
|
get_fake_neutron)
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'adjutant.common.openstack_clients.get_neutronclient',
|
'adjutant.common.openstack_clients.get_neutronclient',
|
||||||
|
@ -54,7 +54,7 @@ class NewUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||||||
return True
|
return True
|
||||||
if user.email != self.email:
|
if user.email != self.email:
|
||||||
self.add_note(
|
self.add_note(
|
||||||
'Found matching username, but email did not match.' +
|
'Found matching username, but email did not match. '
|
||||||
'Reporting as invalid.')
|
'Reporting as invalid.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ class UserDetail(tasks.TaskView):
|
|||||||
if user:
|
if user:
|
||||||
return Response(
|
return Response(
|
||||||
{'errors': [
|
{'errors': [
|
||||||
'Revoking keystone users not implemented. ' +
|
'Revoking keystone users not implemented. '
|
||||||
'Try removing all roles instead.']},
|
'Try removing all roles instead.']},
|
||||||
status=501)
|
status=501)
|
||||||
project_tasks = models.Task.objects.filter(
|
project_tasks = models.Task.objects.filter(
|
||||||
|
@ -52,8 +52,8 @@ class TaskView(APIViewWithLogger):
|
|||||||
self.task_type, settings.DEFAULT_TASK_SETTINGS)
|
self.task_type, settings.DEFAULT_TASK_SETTINGS)
|
||||||
|
|
||||||
actions = (
|
actions = (
|
||||||
class_conf.get('default_actions', []) or
|
class_conf.get('default_actions', [])
|
||||||
self.default_actions[:])
|
or self.default_actions[:])
|
||||||
|
|
||||||
actions += class_conf.get('additional_actions', [])
|
actions += class_conf.get('additional_actions', [])
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ class TaskView(APIViewWithLogger):
|
|||||||
action_serializer_list = []
|
action_serializer_list = []
|
||||||
|
|
||||||
action_names = (
|
action_names = (
|
||||||
class_conf.get('default_actions', []) or
|
class_conf.get('default_actions', [])
|
||||||
self.default_actions[:])
|
or self.default_actions[:])
|
||||||
action_names += class_conf.get('additional_actions', [])
|
action_names += class_conf.get('additional_actions', [])
|
||||||
|
|
||||||
# instantiate all action serializers and check validity
|
# instantiate all action serializers and check validity
|
||||||
@ -369,8 +369,8 @@ class InviteUser(TaskView):
|
|||||||
self.logger.info("(%s) - New AttachUser request." % timezone.now())
|
self.logger.info("(%s) - New AttachUser request." % timezone.now())
|
||||||
|
|
||||||
# Default project_id to the keystone user's project
|
# Default project_id to the keystone user's project
|
||||||
if ('project_id' not in request.data or
|
if ('project_id' not in request.data
|
||||||
request.data['project_id'] is None):
|
or request.data['project_id'] is None):
|
||||||
request.data['project_id'] = request.keystone_user['project_id']
|
request.data['project_id'] = request.keystone_user['project_id']
|
||||||
|
|
||||||
processed, status = self.process_actions(request)
|
processed, status = self.process_actions(request)
|
||||||
@ -454,8 +454,8 @@ class EditUser(TaskView):
|
|||||||
self.task_type, settings.DEFAULT_TASK_SETTINGS)
|
self.task_type, settings.DEFAULT_TASK_SETTINGS)
|
||||||
|
|
||||||
action_names = (
|
action_names = (
|
||||||
class_conf.get('default_actions', []) or
|
class_conf.get('default_actions', [])
|
||||||
self.default_actions[:])
|
or self.default_actions[:])
|
||||||
|
|
||||||
action_names += class_conf.get('additional_actions', [])
|
action_names += class_conf.get('additional_actions', [])
|
||||||
role_blacklist = class_conf.get('role_blacklist', [])
|
role_blacklist = class_conf.get('role_blacklist', [])
|
||||||
|
@ -1548,7 +1548,7 @@ class AdminAPITests(APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.json()['errors'],
|
response.json()['errors'],
|
||||||
["Error: Something went wrong on the server. " +
|
["Error: Something went wrong on the server. "
|
||||||
"It will be looked into shortly."])
|
"It will be looked into shortly."])
|
||||||
|
|
||||||
new_task = Task.objects.all()[0]
|
new_task = Task.objects.all()[0]
|
||||||
@ -1558,6 +1558,6 @@ class AdminAPITests(APITestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
new_notification.notes,
|
new_notification.notes,
|
||||||
{'errors': [
|
{'errors': [
|
||||||
"Error: KeyError('Forced key error.') while updating task. " +
|
"Error: KeyError('Forced key error.') while updating task. "
|
||||||
"See task itself for details."]})
|
"See task itself for details."]})
|
||||||
self.assertEqual(new_notification.task, new_task)
|
self.assertEqual(new_notification.task, new_task)
|
||||||
|
@ -352,7 +352,7 @@ class TaskViewTests(AdjutantAPITestCase):
|
|||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.json(),
|
response.json(),
|
||||||
{'errors': ['Cannot approve an invalid task. ' +
|
{'errors': ['Cannot approve an invalid task. '
|
||||||
'Update data and rerun pre_approve.']})
|
'Update data and rerun pre_approve.']})
|
||||||
|
|
||||||
def test_new_project_existing_user(self):
|
def test_new_project_existing_user(self):
|
||||||
@ -1394,8 +1394,8 @@ class TaskViewTests(AdjutantAPITestCase):
|
|||||||
class_conf = settings.TASK_SETTINGS.get(
|
class_conf = settings.TASK_SETTINGS.get(
|
||||||
CreateProject.task_type, settings.DEFAULT_TASK_SETTINGS)
|
CreateProject.task_type, settings.DEFAULT_TASK_SETTINGS)
|
||||||
expected_action_names = (
|
expected_action_names = (
|
||||||
class_conf.get('default_actions', []) or
|
class_conf.get('default_actions', [])
|
||||||
CreateProject.default_actions[:])
|
or CreateProject.default_actions[:])
|
||||||
expected_action_names += class_conf.get('additional_actions', [])
|
expected_action_names += class_conf.get('additional_actions', [])
|
||||||
|
|
||||||
actions = new_task.actions
|
actions = new_task.actions
|
||||||
@ -1420,7 +1420,7 @@ class TaskViewTests(AdjutantAPITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.json(),
|
response.json(),
|
||||||
{'errors': ["Error: Something went wrong on the server. " +
|
{'errors': ["Error: Something went wrong on the server. "
|
||||||
"It will be looked into shortly."]})
|
"It will be looked into shortly."]})
|
||||||
|
|
||||||
new_task = Task.objects.all()[0]
|
new_task = Task.objects.all()[0]
|
||||||
@ -1430,6 +1430,6 @@ class TaskViewTests(AdjutantAPITestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
new_notification.notes,
|
new_notification.notes,
|
||||||
{'errors': [
|
{'errors': [
|
||||||
"Error: KeyError('Forced key error.') while setting up " +
|
"Error: KeyError('Forced key error.') while setting up "
|
||||||
"task. See task itself for details."]})
|
"task. See task itself for details."]})
|
||||||
self.assertEqual(new_notification.task, new_task)
|
self.assertEqual(new_notification.task, new_task)
|
||||||
|
@ -74,8 +74,8 @@ def send_stage_email(task, email_conf, token=None):
|
|||||||
if len(emails) > 1:
|
if len(emails) > 1:
|
||||||
notes = {
|
notes = {
|
||||||
'errors':
|
'errors':
|
||||||
(("Error: Unable to send update, more than one email for" +
|
("Error: Unable to send update, more than one email for task: %s"
|
||||||
" task: %s") % task.uuid)
|
% task.uuid)
|
||||||
}
|
}
|
||||||
create_notification(task, notes, error=True)
|
create_notification(task, notes, error=True)
|
||||||
return
|
return
|
||||||
@ -231,8 +231,8 @@ def parse_filters(func, *args, **kwargs):
|
|||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError):
|
||||||
return Response(
|
return Response(
|
||||||
{'errors': [
|
{'errors': [
|
||||||
("Filters incorrectly formatted. Required format: " +
|
"Filters incorrectly formatted. Required format: "
|
||||||
"{'filters': {'fieldname': { 'operation': 'value'}}")
|
"{'filters': {'fieldname': { 'operation': 'value'}}"
|
||||||
]},
|
]},
|
||||||
status=400
|
status=400
|
||||||
)
|
)
|
||||||
|
@ -50,15 +50,15 @@ class APIViewWithLogger(APIView):
|
|||||||
timezone.now(), e, trace))
|
timezone.now(), e, trace))
|
||||||
notes = {
|
notes = {
|
||||||
'errors':
|
'errors':
|
||||||
[("Error: %s(%s) %s. See task " +
|
["Error: %s(%s) %s. See task itself for details."
|
||||||
"itself for details.") % (type(e).__name__, e, error_text)]
|
% (type(e).__name__, e, error_text)]
|
||||||
}
|
}
|
||||||
create_notification(task, notes, error=True)
|
create_notification(task, notes, error=True)
|
||||||
|
|
||||||
response_dict = {
|
response_dict = {
|
||||||
'errors':
|
'errors':
|
||||||
["Error: Something went wrong on the " +
|
["Error: Something went wrong on the server. "
|
||||||
"server. It will be looked into shortly."]
|
"It will be looked into shortly."]
|
||||||
}
|
}
|
||||||
if return_response:
|
if return_response:
|
||||||
return Response(response_dict, status=500)
|
return Response(response_dict, status=500)
|
||||||
@ -396,7 +396,7 @@ class TaskDetail(APIViewWithLogger):
|
|||||||
if not valid:
|
if not valid:
|
||||||
return Response(
|
return Response(
|
||||||
{'errors':
|
{'errors':
|
||||||
['Cannot approve an invalid task. ' +
|
['Cannot approve an invalid task. '
|
||||||
'Update data and rerun pre_approve.']},
|
'Update data and rerun pre_approve.']},
|
||||||
status=400)
|
status=400)
|
||||||
|
|
||||||
@ -689,8 +689,8 @@ class TokenDetail(APIViewWithLogger):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
errors[field] = ["This field is required.", ]
|
errors[field] = ["This field is required.", ]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
errors = ["Improperly formated json. " +
|
errors = ["Improperly formated json. "
|
||||||
"Should be a key-value object.", ]
|
"Should be a key-value object."]
|
||||||
break
|
break
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
|
@ -201,8 +201,8 @@ class QuotaManager(object):
|
|||||||
self._quota_updaters[service]
|
self._quota_updaters[service]
|
||||||
|
|
||||||
self.project_id = project_id
|
self.project_id = project_id
|
||||||
self.size_diff_threshold = (size_difference_threshold or
|
self.size_diff_threshold = (size_difference_threshold
|
||||||
self.default_size_diff_threshold)
|
or self.default_size_diff_threshold)
|
||||||
|
|
||||||
def get_current_region_quota(self, region_id):
|
def get_current_region_quota(self, region_id):
|
||||||
current_quota = {}
|
current_quota = {}
|
||||||
|
@ -186,8 +186,8 @@ class FakeManager(object):
|
|||||||
domain = self._domain_from_id(domain)
|
domain = self._domain_from_id(domain)
|
||||||
global identity_cache
|
global identity_cache
|
||||||
for user in identity_cache['users'].values():
|
for user in identity_cache['users'].values():
|
||||||
if (user.name.lower() == name.lower() and
|
if (user.name.lower() == name.lower()
|
||||||
user.domain_id == domain.id):
|
and user.domain_id == domain.id):
|
||||||
return user
|
return user
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -291,8 +291,8 @@ class FakeManager(object):
|
|||||||
roles = []
|
roles = []
|
||||||
|
|
||||||
for assignment in identity_cache['role_assignments']:
|
for assignment in identity_cache['role_assignments']:
|
||||||
if (assignment.user['id'] == user.id and
|
if (assignment.user['id'] == user.id
|
||||||
assignment.scope['project']['id'] == project.id):
|
and assignment.scope['project']['id'] == project.id):
|
||||||
|
|
||||||
if (assignment.scope.get('OS-INHERIT:inherited_to') and not
|
if (assignment.scope.get('OS-INHERIT:inherited_to') and not
|
||||||
inherited) or (
|
inherited) or (
|
||||||
@ -364,8 +364,8 @@ class FakeManager(object):
|
|||||||
domain = self._domain_from_id(domain)
|
domain = self._domain_from_id(domain)
|
||||||
global identity_cache
|
global identity_cache
|
||||||
for project in identity_cache['projects'].values():
|
for project in identity_cache['projects'].values():
|
||||||
if (project.name.lower() == project_name.lower() and
|
if (project.name.lower() == project_name.lower()
|
||||||
project.domain_id == domain.id):
|
and project.domain_id == domain.id):
|
||||||
return project
|
return project
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
2
tox.ini
2
tox.ini
@ -45,7 +45,7 @@ commands =
|
|||||||
|
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = D100,D101,D102,D103,D104,D105,D200,D203,D202,D204,D205,D208,D400,D401
|
ignore = D100,D101,D102,D103,D104,D105,D200,D203,D202,D204,D205,D208,D400,D401,W503
|
||||||
show-source = true
|
show-source = true
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,venv,.env,env,.git,.tox,dist,doc,*lib/python*,*egg,adjutant/api/migrations/*,adjutant/actions/migrations
|
exclude=.venv,venv,.env,env,.git,.tox,dist,doc,*lib/python*,*egg,adjutant/api/migrations/*,adjutant/actions/migrations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user