From 23f40ac4aad0e47a972e79362b720980500ba128 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 27 Apr 2016 20:31:02 -0400 Subject: [PATCH] PEP8 cleanups. --- mayan/apps/acls/tests/test_views.py | 2 +- mayan/apps/common/generics.py | 1 - mayan/apps/django_gpg/tests/literals.py | 2 +- mayan/apps/django_gpg/tests/test_models.py | 21 ++++++++------ mayan/apps/document_signatures/managers.py | 2 +- .../document_signatures/tests/test_models.py | 3 -- .../document_signatures/tests/test_views.py | 4 +-- .../migrations/0033_auto_20160325_0052.py | 7 +++-- mayan/apps/documents/models.py | 1 - mayan/apps/documents/tests/test_events.py | 29 +++---------------- mayan/apps/folders/tests/test_models.py | 3 -- mayan/apps/linking/tests/test_views.py | 3 +- mayan/apps/mailer/tests/test_views.py | 4 +-- mayan/settings/base.py | 10 +++---- 14 files changed, 32 insertions(+), 60 deletions(-) diff --git a/mayan/apps/acls/tests/test_views.py b/mayan/apps/acls/tests/test_views.py index ddc450f5df..52d0e74afc 100644 --- a/mayan/apps/acls/tests/test_views.py +++ b/mayan/apps/acls/tests/test_views.py @@ -8,7 +8,7 @@ from user_management.tests import ( ) from ..models import AccessControlList -from ..permissions import permission_acl_edit, permission_acl_view +from ..permissions import permission_acl_edit class AccessControlListViewTestCase(GenericDocumentViewTestCase): diff --git a/mayan/apps/common/generics.py b/mayan/apps/common/generics.py index 639c5cecea..d79cfb145d 100644 --- a/mayan/apps/common/generics.py +++ b/mayan/apps/common/generics.py @@ -8,7 +8,6 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import ( FormView as DjangoFormView, DetailView, TemplateView ) -from django.views.generic.base import ContextMixin from django.views.generic.detail import SingleObjectMixin from django.views.generic.edit import ( CreateView, DeleteView, ModelFormMixin, UpdateView diff --git a/mayan/apps/django_gpg/tests/literals.py b/mayan/apps/django_gpg/tests/literals.py index 8e4fc83174..eb1fc37ceb 100644 --- a/mayan/apps/django_gpg/tests/literals.py +++ b/mayan/apps/django_gpg/tests/literals.py @@ -89,7 +89,7 @@ TEST_SIGNED_FILE = os.path.join( ) TEST_SIGNED_FILE_CONTENT = 'test_file.txt\n' -TEST_RECEIVE_KEY='''-----BEGIN PGP PUBLIC KEY BLOCK----- +TEST_RECEIVE_KEY = '''-----BEGIN PGP PUBLIC KEY BLOCK----- Version: SKS 1.1.5 Comment: Hostname: keyserver.deuxpi.ca diff --git a/mayan/apps/django_gpg/tests/test_models.py b/mayan/apps/django_gpg/tests/test_models.py index 9fba181645..bcec133f40 100644 --- a/mayan/apps/django_gpg/tests/test_models.py +++ b/mayan/apps/django_gpg/tests/test_models.py @@ -21,13 +21,16 @@ from .literals import ( ) MOCK_SEARCH_KEYS_RESPONSE = [ - {'algo': u'1', - 'date': u'1311475606', - 'expires': u'1643601600', - 'keyid': u'607138F1AECC5A5CA31CB7715F3F7F75D210724D', - 'length': u'2048', - 'type': u'pub', - 'uids': [u'Roberto Rosario ']},] + { + 'algo': u'1', + 'date': u'1311475606', + 'expires': u'1643601600', + 'keyid': u'607138F1AECC5A5CA31CB7715F3F7F75D210724D', + 'length': u'2048', + 'type': u'pub', + 'uids': [u'Roberto Rosario '] + } +] def mock_recv_keys(self, keyserver, *keyids): @@ -47,7 +50,7 @@ class KeyTestCase(TestCase): self.assertEqual(key.fingerprint, TEST_KEY_FINGERPRINT) - @mock.patch.object(gnupg.GPG ,'search_keys', autospec=True) + @mock.patch.object(gnupg.GPG, 'search_keys', autospec=True) def test_key_search(self, search_keys): search_keys.return_value = MOCK_SEARCH_KEYS_RESPONSE @@ -59,7 +62,7 @@ class KeyTestCase(TestCase): ] ) - @mock.patch.object(gnupg.GPG ,'recv_keys', autospec=True) + @mock.patch.object(gnupg.GPG, 'recv_keys', autospec=True) def test_key_receive(self, recv_keys): recv_keys.side_effect = mock_recv_keys diff --git a/mayan/apps/document_signatures/managers.py b/mayan/apps/document_signatures/managers.py index 7252d9211c..8601473589 100644 --- a/mayan/apps/document_signatures/managers.py +++ b/mayan/apps/document_signatures/managers.py @@ -38,7 +38,7 @@ class EmbeddedSignatureManager(models.Manager): try: with document_version.open() as file_object: - signature_result = key.sign_file( + key.sign_file( binary=True, file_object=file_object, output=temporary_filename, passphrase=passphrase ) diff --git a/mayan/apps/document_signatures/tests/test_models.py b/mayan/apps/document_signatures/tests/test_models.py index 2d57063591..22994ec6db 100644 --- a/mayan/apps/document_signatures/tests/test_models.py +++ b/mayan/apps/document_signatures/tests/test_models.py @@ -332,9 +332,6 @@ class EmbeddedSignaturesTestCase(TestCase): self.assertEqual(EmbeddedSignature.objects.count(), 1) - with new_version.open() as file_object: - document_content_hash = hashlib.sha256(file_object.read()).hexdigest() - with new_version.open() as file_object: file_object.seek(0, 2) new_size = file_object.tell() diff --git a/mayan/apps/document_signatures/tests/test_views.py b/mayan/apps/document_signatures/tests/test_views.py index c903969b75..adaeebe697 100644 --- a/mayan/apps/document_signatures/tests/test_views.py +++ b/mayan/apps/document_signatures/tests/test_views.py @@ -5,7 +5,7 @@ from django.core.files import File from django_downloadview.test import assert_download_response from django_gpg.models import Key -from documents.models import Document, DocumentVersion +from documents.models import DocumentVersion from documents.tests.literals import TEST_DOCUMENT_PATH from documents.tests.test_views import GenericDocumentViewTestCase from user_management.tests import ( @@ -325,8 +325,6 @@ class SignaturesViewTestCase(GenericDocumentViewTestCase): for document in self.document_type.documents.all(): document.delete(to_trash=False) - from documents.models import DocumentType - old_hooks = DocumentVersion._post_save_hooks DocumentVersion._post_save_hooks = {} for count in range(TEST_UNSIGNED_DOCUMENT_COUNT): diff --git a/mayan/apps/documents/migrations/0033_auto_20160325_0052.py b/mayan/apps/documents/migrations/0033_auto_20160325_0052.py index b3fa863e17..34132feecb 100644 --- a/mayan/apps/documents/migrations/0033_auto_20160325_0052.py +++ b/mayan/apps/documents/migrations/0033_auto_20160325_0052.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): @@ -13,6 +13,9 @@ class Migration(migrations.Migration): operations = [ migrations.AlterModelOptions( name='documenttypefilename', - options={'ordering': ('filename',), 'verbose_name': 'Quick label', 'verbose_name_plural': 'Quick labels'}, + options={ + 'ordering': ('filename',), 'verbose_name': 'Quick label', + 'verbose_name_plural': 'Quick labels' + }, ), ] diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index ed605e11e4..bf41bc742e 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -1,6 +1,5 @@ from __future__ import absolute_import, unicode_literals -import base64 import hashlib import logging import uuid diff --git a/mayan/apps/documents/tests/test_events.py b/mayan/apps/documents/tests/test_events.py index 80eb33f436..a7e20e6c28 100644 --- a/mayan/apps/documents/tests/test_events.py +++ b/mayan/apps/documents/tests/test_events.py @@ -2,38 +2,18 @@ from __future__ import unicode_literals -from django.contrib.contenttypes.models import ContentType -from django.test import override_settings -from django.utils.six import BytesIO - from actstream.models import Action -from common.tests.test_views import GenericViewTestCase -from converter.models import Transformation -from converter.permissions import permission_transformation_delete from user_management.tests.literals import ( TEST_USER_PASSWORD, TEST_USER_USERNAME ) from ..events import event_document_download, event_document_view -from ..literals import DEFAULT_DELETE_PERIOD, DEFAULT_DELETE_TIME_UNIT -from ..models import ( - DeletedDocument, Document, DocumentType, HASH_FUNCTION -) from ..permissions import ( - permission_document_create, permission_document_delete, - permission_document_download, permission_document_properties_edit, - permission_document_restore, permission_document_tools, - permission_document_trash, permission_document_type_create, - permission_document_type_delete, permission_document_type_edit, - permission_document_type_view, permission_document_version_revert, - permission_document_view, permission_empty_trash + permission_document_download, permission_document_view ) -from .literals import ( - TEST_DOCUMENT_TYPE, TEST_DOCUMENT_TYPE_QUICK_LABEL, - TEST_SMALL_DOCUMENT_CHECKSUM, TEST_SMALL_DOCUMENT_PATH -) + from .test_views import GenericDocumentViewTestCase @@ -43,7 +23,6 @@ TEST_TRANSFORMATION_NAME = 'rotate' TEST_TRANSFORMATION_ARGUMENT = 'degrees: 180' - class DocumentEventsTestCase(GenericDocumentViewTestCase): def test_document_download_event_no_permissions(self): self.login( @@ -69,7 +48,7 @@ class DocumentEventsTestCase(GenericDocumentViewTestCase): self.role.permissions.add( permission_document_download.stored_permission ) - response = self.post( + self.post( 'documents:document_download', args=(self.document.pk,), ) @@ -103,7 +82,7 @@ class DocumentEventsTestCase(GenericDocumentViewTestCase): self.role.permissions.add( permission_document_view.stored_permission ) - response = self.get( + self.get( 'documents:document_preview', args=(self.document.pk,), ) diff --git a/mayan/apps/folders/tests/test_models.py b/mayan/apps/folders/tests/test_models.py index ea96c417df..e39a08d55e 100644 --- a/mayan/apps/folders/tests/test_models.py +++ b/mayan/apps/folders/tests/test_models.py @@ -4,9 +4,6 @@ from django.test import TestCase, override_settings from documents.models import DocumentType from documents.tests import TEST_DOCUMENT_PATH, TEST_DOCUMENT_TYPE -from user_management.tests.literals import ( - TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME -) from ..models import Folder diff --git a/mayan/apps/linking/tests/test_views.py b/mayan/apps/linking/tests/test_views.py index f3f6f2121a..039e520a91 100644 --- a/mayan/apps/linking/tests/test_views.py +++ b/mayan/apps/linking/tests/test_views.py @@ -1,6 +1,5 @@ from __future__ import absolute_import, unicode_literals -from documents.permissions import permission_document_view from documents.tests.test_views import GenericDocumentViewTestCase from user_management.tests import ( TEST_USER_USERNAME, TEST_USER_PASSWORD @@ -9,7 +8,7 @@ from user_management.tests import ( from ..models import SmartLink from ..permissions import ( permission_smart_link_create, permission_smart_link_delete, - permission_smart_link_edit, permission_smart_link_view + permission_smart_link_edit ) TEST_SMART_LINK_LABEL = 'test label' diff --git a/mayan/apps/mailer/tests/test_views.py b/mayan/apps/mailer/tests/test_views.py index 6bd26e7fb8..1b90eea945 100644 --- a/mayan/apps/mailer/tests/test_views.py +++ b/mayan/apps/mailer/tests/test_views.py @@ -7,10 +7,8 @@ from user_management.tests.literals import ( TEST_USER_PASSWORD, TEST_USER_USERNAME ) -from ..models import LogEntry from ..permissions import ( - permission_mailing_link, permission_mailing_send_document, - permission_view_error_log + permission_mailing_link, permission_mailing_send_document ) TEST_EMAIL_ADDRESS = 'test@example.com' diff --git a/mayan/settings/base.py b/mayan/settings/base.py index 7845298000..6d8d16e4cf 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -250,11 +250,11 @@ CORS_ORIGIN_ALLOW_ALL = True SWAGGER_SETTINGS = { 'api_version': '1', 'info': { - 'title': _('Mayan EDMS API Documentation'), - 'description': _('Free Open Source Document Management System.'), - 'contact': 'roberto.rosario@mayan-edms.com', - 'license': 'Apache 2.0', - 'licenseUrl': 'http://www.apache.org/licenses/LICENSE-2.0.html' + 'title': _('Mayan EDMS API Documentation'), + 'description': _('Free Open Source Document Management System.'), + 'contact': 'roberto.rosario@mayan-edms.com', + 'license': 'Apache 2.0', + 'licenseUrl': 'http://www.apache.org/licenses/LICENSE-2.0.html' } }