From 03e59ed9649af3430385e0c1358cda08dea93668 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 19 Jun 2019 00:19:18 -0400 Subject: [PATCH] Fix document parsing tool view typo Closes GitLab issue #615. Thanks to Tyler Page (@iamtpage) for the report. Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 + docs/releases/3.2.2.rst | 3 ++ .../apps/document_parsing/tests/test_views.py | 46 +++++++++++++++++-- mayan/apps/document_parsing/views.py | 2 +- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 009fb73fce..680f834ec8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,8 @@ ================== * Fix document type change view. Closes GitLab issue #614 Thanks to Christoph Roeder (@brightdroid) for the report. +* Fix document parsing tool view typo. Closes GitLab issue #615. + Thanks to Tyler Page (@iamtpage) for the report. 3.2.1 (2019-06-14) ================== diff --git a/docs/releases/3.2.2.rst b/docs/releases/3.2.2.rst index 19101246dc..ffa538c459 100644 --- a/docs/releases/3.2.2.rst +++ b/docs/releases/3.2.2.rst @@ -9,6 +9,8 @@ Changes - Fix document type change view. Closes GitLab issue #614. Thanks to Christoph Roeder (@brightdroid) for the report. +- Fix document parsing tool view typo. Closes GitLab issue #615. + Thanks to Tyler Page (@iamtpage) for the report. Removals -------- @@ -98,5 +100,6 @@ Bugs fixed or issues closed --------------------------- - :gitlab-issue:`614` change type exception +- :gitlab-issue:`615` TypeError: success() got an unexpected keyword argument 'requrest' .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/document_parsing/tests/test_views.py b/mayan/apps/document_parsing/tests/test_views.py index b964e4aab9..37bc00d990 100644 --- a/mayan/apps/document_parsing/tests/test_views.py +++ b/mayan/apps/document_parsing/tests/test_views.py @@ -6,9 +6,7 @@ from mayan.apps.documents.tests import ( GenericDocumentViewTestCase, TEST_HYBRID_DOCUMENT ) -from ..permissions import ( - permission_content_view, permission_document_type_parsing_setup -) +from ..permissions import permission_content_view, permission_parse_document from ..utils import get_document_content from .literals import TEST_DOCUMENT_CONTENT @@ -100,9 +98,49 @@ class DocumentContentViewsTestCase(GenericDocumentViewTestCase): def test_document_type_parsing_settings_view_with_access(self): self.grant_access( - permission=permission_document_type_parsing_setup, + permission=permission_parse_document, obj=self.test_document.document_type ) response = self._request_test_document_type_parsing_settings() self.assertEqual(response.status_code, 200) + + +class DocumentContentToolsViewsTestCase(GenericDocumentViewTestCase): + _skip_file_descriptor_test = True + + # Ensure we use a PDF file + test_document_filename = TEST_HYBRID_DOCUMENT + + def _request_document_parsing_tool_view(self): + return self.post( + viewname='document_parsing:document_type_submit', data={ + 'document_type': self.test_document_type.pk + } + ) + + def _get_document_content(self): + return ''.join(list(get_document_content(document=self.test_document))) + + def test_document_parsing_tool_view_no_permission(self): + + response = self._request_document_parsing_tool_view() + self.assertEqual(response.status_code, 200) + self.assertNotContains( + response=response, status_code=200, + text=self.test_document_type.label + ) + + self.assertNotEqual( + self._get_document_content(), TEST_DOCUMENT_CONTENT + ) + + def test_document_parsing_tool_view_with_permission(self): + self.grant_permission(permission=permission_parse_document) + + response = self._request_document_parsing_tool_view() + self.assertEqual(response.status_code, 302) + + self.assertEqual( + self._get_document_content(), TEST_DOCUMENT_CONTENT + ) diff --git a/mayan/apps/document_parsing/views.py b/mayan/apps/document_parsing/views.py index 0f1d41139d..5256fc7c6d 100644 --- a/mayan/apps/document_parsing/views.py +++ b/mayan/apps/document_parsing/views.py @@ -185,7 +185,7 @@ class DocumentTypeSubmitView(FormView): '%(count)d documents added to the parsing queue.' ) % { 'count': count, - }, requrest=self.request + }, request=self.request ) return HttpResponseRedirect(redirect_to=self.get_success_url())