Rename the DeletedDocument proxy model to a TrashedDocument. Rename the deleted_document views to trashed_document. Rename the document and deleted_document URL parameters to trashed_document. Update URL parameters to the '_id' form. Add keyword arguments. Update use of .filter_by_access(). Enclose trashed document restore method in a transaction. Sort arguments. Update app for compliance with MERCs 5 and 6. Add document page view tests. Add favorite document view tests. Movernize tests. Replace use of urlencode with furl. Update views to use ExternalObjectMixin. Refactor the document and version download views. Rename the DocumentDocumentTypeEditView to DocumentChangeTypeView. Move the trashed document views to their own module. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from mayan.apps.common.tests import BaseTestCase
|
|
from mayan.apps.documents.permissions import permission_document_view
|
|
from mayan.apps.documents.search import document_page_search, document_search
|
|
from mayan.apps.documents.tests import DocumentTestMixin
|
|
|
|
|
|
class DocumentSearchTestCase(DocumentTestMixin, BaseTestCase):
|
|
def _perform_document_page_search(self):
|
|
return document_page_search.search(
|
|
query_string={'q': self.document.label}, user=self._test_case_user
|
|
)
|
|
|
|
def _perform_document_search(self):
|
|
return document_search.search(
|
|
query_string={'q': self.document.label}, user=self._test_case_user
|
|
)
|
|
|
|
def test_document_page_search_no_access(self):
|
|
queryset = self._perform_document_page_search()
|
|
self.assertFalse(self.document.pages.first() in queryset)
|
|
|
|
def test_document_page_search_with_access(self):
|
|
self.grant_access(
|
|
permission=permission_document_view, obj=self.document
|
|
)
|
|
queryset = self._perform_document_page_search()
|
|
self.assertTrue(self.document.pages.first() in queryset)
|
|
|
|
def test_document_search_no_access(self):
|
|
queryset = self._perform_document_search()
|
|
self.assertFalse(self.document in queryset)
|
|
|
|
def test_document_search_with_access(self):
|
|
self.grant_access(
|
|
permission=permission_document_view, obj=self.document
|
|
)
|
|
queryset = self._perform_document_search()
|
|
self.assertTrue(self.document in queryset)
|