Backport test case improvements

Add random primary key mixin. Split test case code into mixins.
Make the view test case and the API test cases part of the same
class hierachy. Update tests that failed due to the new import
locations.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-02 02:31:35 -04:00
parent 8cbae9021b
commit 586d41eeff
13 changed files with 310 additions and 266 deletions

View File

@@ -135,6 +135,7 @@ class DocumentTypeAPITestCase(BaseAPITestCase):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_document_type_delete_with_access(self):
self.expected_content_type = None
self.document_type = DocumentType.objects.create(
label=TEST_DOCUMENT_TYPE_LABEL
)
@@ -522,6 +523,8 @@ class TrashedDocumentAPITestCase(DocumentTestMixin, BaseAPITestCase):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_document_move_to_trash_with_access(self):
self.expected_content_type = None
self.document = self.upload_document()
self.grant_access(
permission=permission_document_trash, obj=self.document
@@ -546,6 +549,8 @@ class TrashedDocumentAPITestCase(DocumentTestMixin, BaseAPITestCase):
self.assertEqual(Document.trash.count(), 1)
def test_trashed_document_delete_from_trash_with_access(self):
self.expected_content_type = None
self.document = self.upload_document()
self.document.delete()
self.grant_access(permission=permission_document_delete, obj=self.document)