From 321edba5f7ed118718d0281ce2607e7ba2b30885 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 25 Sep 2016 13:02:36 +0200 Subject: [PATCH] Reformat code with PyCharm --- gvacommon/__init__.py | 2 +- gvacommon/celeryrouters.py | 1 - gvacommon/settings_utils.py | 4 +--- gvacommon/tests/test_celeryrouters.py | 2 +- gvacommon/tests/test_settings_utils.py | 6 +++--- gvacommon/tests/test_viewmixins.py | 2 +- gvacommon/viewmixins.py | 6 +++--- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/gvacommon/__init__.py b/gvacommon/__init__.py index f9aae42..33e038d 100644 --- a/gvacommon/__init__.py +++ b/gvacommon/__init__.py @@ -15,4 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -__version__ = '0.3.0' +__version__ = '0.3.1' diff --git a/gvacommon/celeryrouters.py b/gvacommon/celeryrouters.py index 8d6ef68..bf7ec5a 100644 --- a/gvacommon/celeryrouters.py +++ b/gvacommon/celeryrouters.py @@ -19,7 +19,6 @@ from __future__ import unicode_literals class GvaRouter(object): - def route_for_task(self, task, args=None, kwargs=None): for route in ['ldap', 'file', 'mysql', 'pgsql', 'web']: if route in task: diff --git a/gvacommon/settings_utils.py b/gvacommon/settings_utils.py index 6c86b82..9d5528b 100644 --- a/gvacommon/settings_utils.py +++ b/gvacommon/settings_utils.py @@ -16,10 +16,8 @@ # along with this program. If not, see . # -from os import environ -# Normally you should not import ANYTHING from Django directly -# into your settings, but ImproperlyConfigured is an exception. from django.core.exceptions import ImproperlyConfigured +from os import environ def get_env_variable(var_name): diff --git a/gvacommon/tests/test_celeryrouters.py b/gvacommon/tests/test_celeryrouters.py index dd97188..753c1d5 100644 --- a/gvacommon/tests/test_celeryrouters.py +++ b/gvacommon/tests/test_celeryrouters.py @@ -20,13 +20,13 @@ Tests for gvacommon celery router code. """ from __future__ import absolute_import, unicode_literals + import unittest from gvacommon.celeryrouters import GvaRouter class GvaRouteTest(unittest.TestCase): - def test_route_for_task_ldap(self): router = GvaRouter() route = router.route_for_task('ldap') diff --git a/gvacommon/tests/test_settings_utils.py b/gvacommon/tests/test_settings_utils.py index 1abc16c..bdeec67 100644 --- a/gvacommon/tests/test_settings_utils.py +++ b/gvacommon/tests/test_settings_utils.py @@ -16,16 +16,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -import os +from __future__ import absolute_import, unicode_literals + from unittest import TestCase +import os from django.core.exceptions import ImproperlyConfigured from gvacommon.settings_utils import get_env_variable class GetEnvVariableTest(TestCase): - def test_get_existing_env_variable(self): os.environ['testvariable'] = 'myvalue' self.assertEqual(get_env_variable('testvariable'), 'myvalue') @@ -37,4 +38,3 @@ class GetEnvVariableTest(TestCase): get_env_variable('missingvariable') self.assertEqual( str(e.exception), 'Set the missingvariable environment variable') - diff --git a/gvacommon/tests/test_viewmixins.py b/gvacommon/tests/test_viewmixins.py index 2117b4f..2b24270 100644 --- a/gvacommon/tests/test_viewmixins.py +++ b/gvacommon/tests/test_viewmixins.py @@ -20,6 +20,7 @@ Tests for gvacommon code. """ from __future__ import absolute_import, unicode_literals + import unittest try: @@ -73,7 +74,6 @@ class StaffOrSelfLoginRequiredMixinTest(unittest.TestCase): from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin class SubjectView(StaffOrSelfLoginRequiredMixin, View): - def get(self, request, *args, **kwargs): return "success" diff --git a/gvacommon/viewmixins.py b/gvacommon/viewmixins.py index a63d142..061d54d 100644 --- a/gvacommon/viewmixins.py +++ b/gvacommon/viewmixins.py @@ -21,9 +21,9 @@ This module defines mixins for gnuviechadmin views. """ from __future__ import unicode_literals +from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponseForbidden from django.utils.translation import ugettext as _ -from django.contrib.auth.mixins import LoginRequiredMixin class StaffOrSelfLoginRequiredMixin(LoginRequiredMixin): @@ -35,8 +35,8 @@ class StaffOrSelfLoginRequiredMixin(LoginRequiredMixin): def dispatch(self, request, *args, **kwargs): if ( - request.user.is_staff or - request.user == self.get_customer_object() + request.user.is_staff or + request.user == self.get_customer_object() ): return super(StaffOrSelfLoginRequiredMixin, self).dispatch( request, *args, **kwargs