Complete conversion of download views to CBV views using django-downloadview.

This also removes dependency on the filetransfers library.
This commit is contained in:
Roberto Rosario
2016-10-31 01:00:35 -04:00
parent 24ef702e9c
commit 6e3d99670c
37 changed files with 437 additions and 340 deletions

View File

@@ -3,8 +3,8 @@
from __future__ import unicode_literals
from actstream.models import Action
from django_downloadview import assert_download_response
from common.tests import skip_file_descriptor_check
from user_management.tests.literals import (
TEST_USER_PASSWORD, TEST_USER_USERNAME
)
@@ -14,7 +14,6 @@ from ..permissions import (
permission_document_download, permission_document_view
)
from .test_views import GenericDocumentViewTestCase
@@ -32,17 +31,14 @@ class DocumentEventsTestCase(GenericDocumentViewTestCase):
Action.objects.all().delete()
response = self.post(
response = self.get(
'documents:document_download', args=(self.document.pk,)
)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.status_code, 403)
self.assertEqual(list(Action.objects.any(obj=self.document)), [])
@skip_file_descriptor_check
def test_document_download_event_with_permissions(self):
# TODO: Skip this test's file descriptor check until it gets migrate
# SingleObjectDownloadView CBV
self.login(
username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD
)
@@ -53,12 +49,19 @@ class DocumentEventsTestCase(GenericDocumentViewTestCase):
permission_document_download.stored_permission
)
self.expected_content_type = 'image/png'
self.expected_content_type = 'image/png; charset=utf-8'
self.post(
response = self.get(
'documents:document_download', args=(self.document.pk,),
)
# Download the file to close the file descriptor
with self.document.open() as file_object:
assert_download_response(
self, response, content=file_object.read(),
mime_type=self.document.file_mimetype
)
event = Action.objects.any(obj=self.document).first()
self.assertEqual(event.verb, event_document_download.name)