Fix flake8 warnings
This commit fixes all warnings created by flake8 by removing unused imports and variable assignments. Some wrongly indented lines are now indented correctly.
This commit is contained in:
parent
30600ce107
commit
fb1f31a9bc
12 changed files with 50 additions and 49 deletions
|
@ -7,7 +7,6 @@ from __future__ import absolute_import, unicode_literals
|
|||
import mock
|
||||
from mock import MagicMock, Mock
|
||||
|
||||
from django.core import mail
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test import TestCase
|
||||
from django.contrib.sites.models import Site
|
||||
|
@ -25,7 +24,7 @@ class ContactFormTest(TestCase):
|
|||
|
||||
def test_constructor_needs_request(self):
|
||||
with self.assertRaises(KeyError):
|
||||
form = ContactForm()
|
||||
ContactForm()
|
||||
|
||||
def test_constructor(self):
|
||||
request = MagicMock()
|
||||
|
|
|
@ -26,8 +26,8 @@ class ContactFormViewTest(TestCase):
|
|||
|
||||
def _setup_user(self, **kwargs):
|
||||
return User.objects.create_user(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD,
|
||||
**kwargs)
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD,
|
||||
**kwargs)
|
||||
|
||||
def test_get_contact_form_template(self):
|
||||
response = self.client.get(reverse('contact_form'))
|
||||
|
@ -64,28 +64,28 @@ class ContactFormViewTest(TestCase):
|
|||
self.assertEqual(len(form.errors), 3)
|
||||
|
||||
def test_post_empty_form_no_mail(self):
|
||||
response = self.client.post(reverse('contact_form'), {})
|
||||
self.client.post(reverse('contact_form'), {})
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
def test_get_contact_form_logged_in_no_fullname_initial(self):
|
||||
user = self._setup_user()
|
||||
self._setup_user()
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(reverse('contact_form'))
|
||||
self.assertIn('form', response.context)
|
||||
form = response.context['form']
|
||||
self.assertEqual(
|
||||
form.initial, {'name': TEST_USER, 'email': TEST_EMAIL})
|
||||
form.initial, {'name': TEST_USER, 'email': TEST_EMAIL})
|
||||
|
||||
def test_get_contact_form_logged_in_fullname_initial(self):
|
||||
user = self._setup_user(
|
||||
first_name=TEST_NAME[0], last_name=TEST_NAME[1])
|
||||
self._setup_user(
|
||||
first_name=TEST_NAME[0], last_name=TEST_NAME[1])
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(reverse('contact_form'))
|
||||
self.assertIn('form', response.context)
|
||||
form = response.context['form']
|
||||
self.assertEqual(
|
||||
form.initial,
|
||||
{'name': " ".join(TEST_NAME), 'email': TEST_EMAIL})
|
||||
form.initial,
|
||||
{'name': " ".join(TEST_NAME), 'email': TEST_EMAIL})
|
||||
|
||||
def test_post_filled_form_anonymous_redirects(self):
|
||||
response = self.client.post(reverse('contact_form'), {
|
||||
|
@ -93,24 +93,24 @@ class ContactFormViewTest(TestCase):
|
|||
self.assertRedirects(response, reverse('contact_success'))
|
||||
|
||||
def test_post_filled_form_anonymous_mail(self):
|
||||
response = self.client.post(reverse('contact_form'), {
|
||||
self.client.post(reverse('contact_form'), {
|
||||
'name': TEST_USER, 'email': TEST_EMAIL, 'body': TEST_MESSAGE})
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
|
||||
def test_post_filled_form_logged_in_redirects(self):
|
||||
user = self._setup_user(
|
||||
first_name=TEST_NAME[0], last_name=TEST_NAME[1])
|
||||
self._setup_user(
|
||||
first_name=TEST_NAME[0], last_name=TEST_NAME[1])
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.post(reverse('contact_form'), {
|
||||
'name': " ".join(TEST_NAME), 'email': TEST_EMAIL,
|
||||
'body': TEST_MESSAGE})
|
||||
self.assertRedirects(response, reverse('contact_success'))
|
||||
|
||||
def test_post_filled_form_logged_in_redirects(self):
|
||||
user = self._setup_user(
|
||||
first_name=TEST_NAME[0], last_name=TEST_NAME[1])
|
||||
def test_post_filled_form_logged_in_mail(self):
|
||||
self._setup_user(
|
||||
first_name=TEST_NAME[0], last_name=TEST_NAME[1])
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.post(reverse('contact_form'), {
|
||||
self.client.post(reverse('contact_form'), {
|
||||
'name': " ".join(TEST_NAME), 'email': TEST_EMAIL,
|
||||
'body': TEST_MESSAGE})
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
|
|
|
@ -4,7 +4,7 @@ Tests for :py:mod:`domains.models`.
|
|||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from mock import Mock, MagicMock, patch
|
||||
from mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth import get_user_model
|
||||
|
|
|
@ -58,7 +58,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_get_staff_user(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(
|
||||
|
@ -69,7 +69,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_get_template(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(
|
||||
|
@ -78,7 +78,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
self.assertTemplateUsed(response, 'domains/hostingdomain_create.html')
|
||||
|
||||
def test_get_no_package_found(self):
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(
|
||||
|
@ -89,7 +89,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_get_get_form_kwargs(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
view = CreateHostingDomain(
|
||||
|
@ -101,7 +101,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_get_context_data_has_hosting_package(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(
|
||||
|
@ -113,7 +113,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_get_context_data_has_customer(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.get(
|
||||
|
@ -125,7 +125,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_form_valid_redirect(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.post(
|
||||
|
@ -137,7 +137,7 @@ class CreateHostingDomainTest(TestCase):
|
|||
def test_form_valid_message(self):
|
||||
customer = User.objects.create_user('customer')
|
||||
package = self._setup_hosting_package(customer)
|
||||
admin = User.objects.create_superuser(
|
||||
User.objects.create_superuser(
|
||||
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
response = self.client.post(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from gnuviechadmin.celery import app as celery_app
|
||||
# import celery_app to initialize it
|
||||
from gnuviechadmin.celery import app as celery_app # NOQA
|
||||
|
||||
__version__ = '0.12.dev1'
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .base import *
|
||||
# use import * to import all settings from base
|
||||
from .base import * # NOQA
|
||||
|
||||
|
||||
# ######### DEBUG CONFIGURATION
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .base import *
|
||||
# use import * to import all settings from base
|
||||
from .base import * # NOQA
|
||||
|
||||
# ######### HOST CONFIGURATION
|
||||
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production # noqa
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from .base import *
|
||||
# use import * to import all settings from base
|
||||
from .base import * # NOQA
|
||||
|
||||
PASSWORD_HASHERS = (
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
|
|
|
@ -56,7 +56,7 @@ class NavigationContextProcessorTest(TestCase):
|
|||
self.assertEqual(response.context['active_item'], 'contact')
|
||||
|
||||
def test_hostingpackage_page_context(self):
|
||||
user = User.objects.create_user('test', password='test')
|
||||
User.objects.create_user('test', password='test')
|
||||
self.client.login(username='test', password='test')
|
||||
response = self.client.get(
|
||||
reverse('hosting_packages', kwargs={'user': 'test'}))
|
||||
|
|
|
@ -18,4 +18,9 @@ class OsusersAppConfig(AppConfig):
|
|||
verbose_name = _('Operating System Users and Groups')
|
||||
|
||||
def ready(self):
|
||||
import osusers.signals
|
||||
"""
|
||||
Takes care of importing the signal handlers of the :py:mod:`osusers`
|
||||
app.
|
||||
|
||||
"""
|
||||
import osusers.signals # NOQA
|
||||
|
|
|
@ -10,8 +10,6 @@ import logging
|
|||
import os
|
||||
import six
|
||||
|
||||
from celery import group
|
||||
|
||||
from django.db import models, transaction
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -25,8 +23,6 @@ from model_utils.models import TimeStampedModel
|
|||
from passlib.hash import sha512_crypt
|
||||
from passlib.utils import generate_password
|
||||
|
||||
from taskresults.models import TaskResult
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -7,14 +7,11 @@ from __future__ import absolute_import, unicode_literals
|
|||
import logging
|
||||
|
||||
from django.db.models.signals import (
|
||||
m2m_changed,
|
||||
post_delete,
|
||||
post_save,
|
||||
)
|
||||
from django.dispatch import receiver
|
||||
|
||||
from celery import chain, group
|
||||
|
||||
from fileservertasks.tasks import (
|
||||
delete_file_mail_userdir,
|
||||
delete_file_sftp_userdir,
|
||||
|
@ -80,11 +77,11 @@ def handle_group_created(sender, instance, created, **kwargs):
|
|||
def handle_user_created(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
chain = create_ldap_user.s(
|
||||
instance.username, instance.uid, instance.group.gid,
|
||||
instance.gecos, instance.homedir, instance.shell, None
|
||||
) | setup_file_sftp_userdir.s(
|
||||
instance.username
|
||||
) | setup_file_mail_userdir.s(instance.username)
|
||||
instance.username, instance.uid, instance.group.gid,
|
||||
instance.gecos, instance.homedir, instance.shell, None
|
||||
) | setup_file_sftp_userdir.s(
|
||||
instance.username
|
||||
) | setup_file_mail_userdir.s(instance.username)
|
||||
taskresult = TaskResult.objects.create_task_result(
|
||||
'handle_user_created', chain)
|
||||
_LOGGER.info(
|
||||
|
@ -140,10 +137,10 @@ def handle_group_deleted(sender, instance, **kwargs):
|
|||
@receiver(post_delete, sender=User)
|
||||
def handle_user_deleted(sender, instance, **kwargs):
|
||||
chain = delete_file_mail_userdir.s(
|
||||
instance.username
|
||||
) | delete_file_sftp_userdir.s(
|
||||
instance.username
|
||||
) | delete_ldap_user.s(instance.username)
|
||||
instance.username
|
||||
) | delete_file_sftp_userdir.s(
|
||||
instance.username
|
||||
) | delete_ldap_user.s(instance.username)
|
||||
_LOGGER.debug('chain signature %s', chain)
|
||||
taskresult = TaskResult.objects.create_task_result(
|
||||
'handle_user_deleted', chain)
|
||||
|
|
Loading…
Reference in a new issue