Test simplification

Unify usage of self.test_document and self.test_documents in
tests.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-05-07 00:54:59 -04:00
parent ebc68d3c36
commit a0d2000419
36 changed files with 306 additions and 276 deletions
+6 -6
View File
@@ -9,32 +9,32 @@ 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
query_string={'q': self.test_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
query_string={'q': self.test_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)
self.assertFalse(self.test_document.pages.first() in queryset)
def test_document_page_search_with_access(self):
self.grant_access(
obj=self.test_document, permission=permission_document_view
)
queryset = self._perform_document_page_search()
self.assertTrue(self.document.pages.first() in queryset)
self.assertTrue(self.test_document.pages.first() in queryset)
def test_document_search_no_access(self):
queryset = self._perform_document_search()
self.assertFalse(self.document in queryset)
self.assertFalse(self.test_document in queryset)
def test_document_search_with_access(self):
self.grant_access(
obj=self.test_document, permission=permission_document_view
)
queryset = self._perform_document_search()
self.assertTrue(self.document in queryset)
self.assertTrue(self.test_document in queryset)