From fd8721b297e5fc4b08de96854f3486f7bf13f64f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 12 Jul 2015 03:28:31 -0400 Subject: [PATCH] Add teardown method for all tests. --- mayan/apps/acls/test_models.py | 7 +++++++ mayan/apps/document_indexing/test_models.py | 4 ++++ mayan/apps/document_signatures/test_models.py | 8 ++++---- mayan/apps/documents/test_api.py | 7 ++++--- mayan/apps/dynamic_search/test_views.py | 4 +++- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mayan/apps/acls/test_models.py b/mayan/apps/acls/test_models.py index 8977146162..b66f245189 100644 --- a/mayan/apps/acls/test_models.py +++ b/mayan/apps/acls/test_models.py @@ -43,6 +43,13 @@ class PermissionTestCase(TestCase): self.role = Role.objects.create(label='test role') Permission.invalidate_cache() + def tearDown(self): + for document_type in DocumentType.objects.all(): + document_type.delete() + self.role.delete() + self.group.delete() + self.user.delete() + def test_check_access_without_permissions(self): with self.assertRaises(PermissionDenied): AccessControlList.objects.check_access(permissions=(permission_document_view,), user=self.user, obj=self.document_1) diff --git a/mayan/apps/document_indexing/test_models.py b/mayan/apps/document_indexing/test_models.py index e66964f7af..58b3a515a2 100644 --- a/mayan/apps/document_indexing/test_models.py +++ b/mayan/apps/document_indexing/test_models.py @@ -21,6 +21,10 @@ class IndexTestCase(TestCase): with open(TEST_SMALL_DOCUMENT_PATH) as file_object: self.document = self.document_type.new_document(file_object=File(file_object)) + def tearDown(self): + for document_type in DocumentType.objects.all(): + document_type.delete() + def test_indexing(self): metadata_type = MetadataType.objects.create(name='test', label='test') DocumentTypeMetadataType.objects.create(document_type=self.document_type, metadata_type=metadata_type) diff --git a/mayan/apps/document_signatures/test_models.py b/mayan/apps/document_signatures/test_models.py index b024a2d740..055c07f692 100644 --- a/mayan/apps/document_signatures/test_models.py +++ b/mayan/apps/document_signatures/test_models.py @@ -32,6 +32,10 @@ class DocumentTestCase(TestCase): with open(TEST_KEY_FILE) as file_object: gpg.import_key(file_object.read()) + def tearDown(self): + self.document.delete() + self.document_type.delete() + def test_document_no_signature(self): self.assertEqual(DocumentVersionSignature.objects.has_detached_signature(self.document.latest_version), False) @@ -54,7 +58,3 @@ class DocumentTestCase(TestCase): self.assertEqual(DocumentVersionSignature.objects.has_detached_signature(self.document.latest_version), True) self.assertEqual(DocumentVersionSignature.objects.verify_signature(self.document.latest_version).status, SIGNATURE_STATE_VALID) - - def tearDown(self): - self.document.delete() - self.document_type.delete() diff --git a/mayan/apps/documents/test_api.py b/mayan/apps/documents/test_api.py index efeac40a8f..edad44ef6b 100644 --- a/mayan/apps/documents/test_api.py +++ b/mayan/apps/documents/test_api.py @@ -34,6 +34,10 @@ class DocumentAPICreateDocumentTestCase(TestCase): ocr_settings.auto_ocr = False ocr_settings.save() + def tearDown(self): + self.document_type.delete() + self.admin_user.delete() + def test_uploading_a_document_using_token_auth(self): # Get the an user token token_client = APIClient() @@ -97,6 +101,3 @@ class DocumentAPICreateDocumentTestCase(TestCase): # The document was deleted from the the DB? self.assertEqual(Document.objects.count(), 0) - - def tearDown(self): - self.document_type.delete() diff --git a/mayan/apps/dynamic_search/test_views.py b/mayan/apps/dynamic_search/test_views.py index e0585bc613..1d619e3521 100644 --- a/mayan/apps/dynamic_search/test_views.py +++ b/mayan/apps/dynamic_search/test_views.py @@ -43,7 +43,9 @@ class Issue46TestCase(TestCase): ) def tearDown(self): - DocumentType.objects.all().delete() + for document_type in DocumentType.objects.all(): + document_type.delete() + self.admin_user.delete() def test_advanced_search_past_first_page(self):