From 80f64d7fcfb1fac0774fb141615bddc84485f4dd Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 16 Feb 2017 21:12:55 -0400 Subject: [PATCH] Add BaseAPITestCase class that invalidates the permission and smart settings caches. Use BaseAPITestCase for all API test cases. --- mayan/apps/common/tests/test_api.py | 4 ++-- mayan/apps/django_gpg/tests/test_api.py | 6 +++--- mayan/apps/document_states/tests/test_api.py | 22 ++++++++++++++------ mayan/apps/documents/tests/test_api.py | 18 +++++++++------- mayan/apps/dynamic_search/tests/test_api.py | 11 ++++------ mayan/apps/events/tests/test_api.py | 4 ++-- mayan/apps/folders/tests/test_api.py | 10 +++------ mayan/apps/linking/tests/test_api.py | 12 +++++++---- mayan/apps/metadata/tests/test_api.py | 17 ++++++++++----- mayan/apps/motd/tests/test_api.py | 7 ++++--- mayan/apps/ocr/tests/test_api.py | 7 +++++-- mayan/apps/permissions/tests/test_api.py | 5 ++--- mayan/apps/rest_api/tests/__init__.py | 1 + mayan/apps/rest_api/tests/base.py | 17 +++++++++++++++ mayan/apps/tags/tests/test_api.py | 11 ++++------ mayan/apps/user_management/tests/test_api.py | 19 +++++++---------- 16 files changed, 101 insertions(+), 70 deletions(-) create mode 100644 mayan/apps/rest_api/tests/__init__.py create mode 100644 mayan/apps/rest_api/tests/base.py diff --git a/mayan/apps/common/tests/test_api.py b/mayan/apps/common/tests/test_api.py index 4b92bd8342..2a8f456b1c 100644 --- a/mayan/apps/common/tests/test_api.py +++ b/mayan/apps/common/tests/test_api.py @@ -2,10 +2,10 @@ from __future__ import unicode_literals from django.core.urlresolvers import reverse -from rest_framework.test import APITestCase +from rest_api.tests import BaseAPITestCase -class CommonAPITestCase(APITestCase): +class CommonAPITestCase(BaseAPITestCase): def test_content_type_list_view(self): response = self.client.get(reverse('rest_api:content-type-list')) self.assertEqual(response.status_code, 200) diff --git a/mayan/apps/django_gpg/tests/test_api.py b/mayan/apps/django_gpg/tests/test_api.py index 927fed2ff5..605f973911 100644 --- a/mayan/apps/django_gpg/tests/test_api.py +++ b/mayan/apps/django_gpg/tests/test_api.py @@ -4,8 +4,7 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -16,8 +15,9 @@ from .literals import TEST_KEY_DATA, TEST_KEY_FINGERPRINT @override_settings(OCR_AUTO_OCR=False) -class KeyAPITestCase(APITestCase): +class KeyAPITestCase(BaseAPITestCase): def setUp(self): + super(KeyAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD diff --git a/mayan/apps/document_states/tests/test_api.py b/mayan/apps/document_states/tests/test_api.py index 6545450ee7..fe75a90c25 100644 --- a/mayan/apps/document_states/tests/test_api.py +++ b/mayan/apps/document_states/tests/test_api.py @@ -4,12 +4,11 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - from documents.models import DocumentType from documents.tests.literals import ( TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH ) +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -26,8 +25,9 @@ from .literals import ( @override_settings(OCR_AUTO_OCR=False) -class WorkflowAPITestCase(APITestCase): +class WorkflowAPITestCase(BaseAPITestCase): def setUp(self): + super(WorkflowAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -49,6 +49,7 @@ class WorkflowAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(WorkflowAPITestCase, self).tearDown() def _create_workflow(self): return Workflow.objects.create(label=TEST_WORKFLOW_LABEL) @@ -188,8 +189,10 @@ class WorkflowAPITestCase(APITestCase): @override_settings(OCR_AUTO_OCR=False) -class WorkflowStatesAPITestCase(APITestCase): +class WorkflowStatesAPITestCase(BaseAPITestCase): def setUp(self): + super(WorkflowStatesAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -211,6 +214,7 @@ class WorkflowStatesAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(WorkflowStatesAPITestCase, self).tearDown() def _create_workflow(self): self.workflow = Workflow.objects.create(label=TEST_WORKFLOW_LABEL) @@ -317,8 +321,10 @@ class WorkflowStatesAPITestCase(APITestCase): @override_settings(OCR_AUTO_OCR=False) -class WorkflowTransitionsAPITestCase(APITestCase): +class WorkflowTransitionsAPITestCase(BaseAPITestCase): def setUp(self): + super(WorkflowTransitionsAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -340,6 +346,7 @@ class WorkflowTransitionsAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(WorkflowTransitionsAPITestCase, self).tearDown() def _create_workflow(self): self.workflow = Workflow.objects.create(label=TEST_WORKFLOW_LABEL) @@ -487,8 +494,10 @@ class WorkflowTransitionsAPITestCase(APITestCase): @override_settings(OCR_AUTO_OCR=False) -class DocumentWorkflowsAPITestCase(APITestCase): +class DocumentWorkflowsAPITestCase(BaseAPITestCase): def setUp(self): + super(DocumentWorkflowsAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -505,6 +514,7 @@ class DocumentWorkflowsAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(DocumentWorkflowsAPITestCase, self).tearDown() def _create_document(self): with open(TEST_SMALL_DOCUMENT_PATH) as file_object: diff --git a/mayan/apps/documents/tests/test_api.py b/mayan/apps/documents/tests/test_api.py index 637def9413..f30ebf7f2c 100644 --- a/mayan/apps/documents/tests/test_api.py +++ b/mayan/apps/documents/tests/test_api.py @@ -13,8 +13,8 @@ from django.utils.encoding import force_text from django_downloadview import assert_download_response from rest_framework import status -from rest_framework.test import APITestCase +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -28,12 +28,9 @@ from .literals import ( from ..models import Document, DocumentType -class DocumentTypeAPITestCase(APITestCase): - """ - Test the document type API endpoints - """ - +class DocumentTypeAPITestCase(BaseAPITestCase): def setUp(self): + super(DocumentTypeAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -45,6 +42,7 @@ class DocumentTypeAPITestCase(APITestCase): def tearDown(self): self.admin_user.delete() + super(DocumentTypeAPITestCase, self).tearDown() def test_document_type_create(self): self.assertEqual(DocumentType.objects.all().count(), 0) @@ -94,8 +92,9 @@ class DocumentTypeAPITestCase(APITestCase): @override_settings(OCR_AUTO_OCR=False) -class DocumentAPITestCase(APITestCase): +class DocumentAPITestCase(BaseAPITestCase): def setUp(self): + super(DocumentAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -112,6 +111,7 @@ class DocumentAPITestCase(APITestCase): def tearDown(self): self.admin_user.delete() self.document_type.delete() + super(DocumentAPITestCase, self).tearDown() def _upload_document(self): with open(TEST_SMALL_DOCUMENT_PATH) as file_object: @@ -322,8 +322,9 @@ class DocumentAPITestCase(APITestCase): @override_settings(OCR_AUTO_OCR=False) -class TrashedDocumentAPITestCase(APITestCase): +class TrashedDocumentAPITestCase(BaseAPITestCase): def setUp(self): + super(TrashedDocumentAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -340,6 +341,7 @@ class TrashedDocumentAPITestCase(APITestCase): def tearDown(self): self.admin_user.delete() self.document_type.delete() + super(TrashedDocumentAPITestCase, self).tearDown() def _upload_document(self): with open(TEST_SMALL_DOCUMENT_PATH) as file_object: diff --git a/mayan/apps/dynamic_search/tests/test_api.py b/mayan/apps/dynamic_search/tests/test_api.py index e8483a90a4..252442d847 100644 --- a/mayan/apps/dynamic_search/tests/test_api.py +++ b/mayan/apps/dynamic_search/tests/test_api.py @@ -6,23 +6,20 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - from documents.models import DocumentType from documents.search import document_search from documents.tests import TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH +from rest_api.tests import BaseAPITestCase from user_management.tests import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @override_settings(OCR_AUTO_OCR=False) -class SearchAPITestCase(APITestCase): - """ - Test the search API endpoints - """ - +class SearchAPITestCase(BaseAPITestCase): def setUp(self): + super(SearchAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD diff --git a/mayan/apps/events/tests/test_api.py b/mayan/apps/events/tests/test_api.py index dadc0f531a..63cea28c6c 100644 --- a/mayan/apps/events/tests/test_api.py +++ b/mayan/apps/events/tests/test_api.py @@ -2,10 +2,10 @@ from __future__ import unicode_literals from django.core.urlresolvers import reverse -from rest_framework.test import APITestCase +from rest_api.tests import BaseAPITestCase -class EventAPITestCase(APITestCase): +class EventAPITestCase(BaseAPITestCase): def test_evet_type_list_view(self): response = self.client.get(reverse('rest_api:event-type-list')) self.assertEqual(response.status_code, 200) diff --git a/mayan/apps/folders/tests/test_api.py b/mayan/apps/folders/tests/test_api.py index 333198a4d5..6da4b1b16b 100644 --- a/mayan/apps/folders/tests/test_api.py +++ b/mayan/apps/folders/tests/test_api.py @@ -4,10 +4,9 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - from documents.models import DocumentType from documents.tests import TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -17,12 +16,9 @@ from ..models import Folder from .literals import TEST_FOLDER_EDITED_LABEL, TEST_FOLDER_LABEL -class FolderAPITestCase(APITestCase): - """ - Test the folder API endpoints - """ - +class FolderAPITestCase(BaseAPITestCase): def setUp(self): + super(FolderAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD diff --git a/mayan/apps/linking/tests/test_api.py b/mayan/apps/linking/tests/test_api.py index 4e795f830e..2e791d5cb1 100644 --- a/mayan/apps/linking/tests/test_api.py +++ b/mayan/apps/linking/tests/test_api.py @@ -4,12 +4,11 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - from documents.models import DocumentType from documents.tests.literals import ( TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH ) +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -26,8 +25,9 @@ from .literals import ( @override_settings(OCR_AUTO_OCR=False) -class SmartLinkAPITestCase(APITestCase): +class SmartLinkAPITestCase(BaseAPITestCase): def setUp(self): + super(SmartLinkAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -40,6 +40,7 @@ class SmartLinkAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(SmartLinkAPITestCase, self).tearDown() def _create_document_type(self): self.document_type = DocumentType.objects.create( @@ -122,8 +123,10 @@ class SmartLinkAPITestCase(APITestCase): @override_settings(OCR_AUTO_OCR=False) -class SmartLinkConditionAPITestCase(APITestCase): +class SmartLinkConditionAPITestCase(BaseAPITestCase): def setUp(self): + super(SmartLinkConditionAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -136,6 +139,7 @@ class SmartLinkConditionAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(SmartLinkConditionAPITestCase, self).tearDown() def _create_document_type(self): self.document_type = DocumentType.objects.create( diff --git a/mayan/apps/metadata/tests/test_api.py b/mayan/apps/metadata/tests/test_api.py index 79ccff4acb..4a9f47c4e0 100644 --- a/mayan/apps/metadata/tests/test_api.py +++ b/mayan/apps/metadata/tests/test_api.py @@ -4,10 +4,9 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - from documents.models import DocumentType from documents.tests import TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -21,8 +20,10 @@ from .literals import ( ) -class MetadataTypeAPITestCase(APITestCase): +class MetadataTypeAPITestCase(BaseAPITestCase): def setUp(self): + super(MetadataTypeAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -125,8 +126,10 @@ class MetadataTypeAPITestCase(APITestCase): ) -class DocumentTypeMetadataTypeAPITestCase(APITestCase): +class DocumentTypeMetadataTypeAPITestCase(BaseAPITestCase): def setUp(self): + super(DocumentTypeMetadataTypeAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -147,6 +150,7 @@ class DocumentTypeMetadataTypeAPITestCase(APITestCase): def tearDown(self): self.admin_user.delete() self.document_type.delete() + super(DocumentTypeMetadataTypeAPITestCase, self).tearDown() def test_document_type_metadata_type_optional_create(self): response = self.client.post( @@ -205,9 +209,11 @@ class DocumentTypeMetadataTypeAPITestCase(APITestCase): self.assertEqual(self.document_type.metadata.all().count(), 0) -class DocumentMetadataAPITestCase(APITestCase): +class DocumentMetadataAPITestCase(BaseAPITestCase): @override_settings(OCR_AUTO_OCR=False) def setUp(self): + super(DocumentMetadataAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -237,6 +243,7 @@ class DocumentMetadataAPITestCase(APITestCase): def tearDown(self): self.admin_user.delete() self.document_type.delete() + super(DocumentMetadataAPITestCase, self).tearDown() def test_document_metadata_create(self): response = self.client.post( diff --git a/mayan/apps/motd/tests/test_api.py b/mayan/apps/motd/tests/test_api.py index 84efa6c422..53b6ba7c30 100644 --- a/mayan/apps/motd/tests/test_api.py +++ b/mayan/apps/motd/tests/test_api.py @@ -4,8 +4,7 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from django.test import override_settings -from rest_framework.test import APITestCase - +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -18,8 +17,10 @@ from .literals import ( @override_settings(OCR_AUTO_OCR=False) -class MOTDAPITestCase(APITestCase): +class MOTDAPITestCase(BaseAPITestCase): def setUp(self): + super(MOTDAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD diff --git a/mayan/apps/ocr/tests/test_api.py b/mayan/apps/ocr/tests/test_api.py index 1194a76748..181ff14ca1 100644 --- a/mayan/apps/ocr/tests/test_api.py +++ b/mayan/apps/ocr/tests/test_api.py @@ -6,21 +6,23 @@ from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse from rest_framework import status -from rest_framework.test import APITestCase from documents.models import DocumentType from documents.tests import TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH +from rest_api.tests import BaseAPITestCase from user_management.tests import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) -class OCRAPITestCase(APITestCase): +class OCRAPITestCase(BaseAPITestCase): """ Test the OCR app API endpoints """ def setUp(self): + super(OCRAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -41,6 +43,7 @@ class OCRAPITestCase(APITestCase): def tearDown(self): self.document_type.delete() + super(OCRAPITestCase, self).tearDown() def test_submit_document(self): response = self.client.post( diff --git a/mayan/apps/permissions/tests/test_api.py b/mayan/apps/permissions/tests/test_api.py index 5a6d39ce12..76f379a230 100644 --- a/mayan/apps/permissions/tests/test_api.py +++ b/mayan/apps/permissions/tests/test_api.py @@ -4,8 +4,7 @@ from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.core.urlresolvers import reverse -from rest_framework.test import APITestCase - +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME, TEST_GROUP_NAME @@ -18,7 +17,7 @@ from ..permissions import permission_role_view from .literals import TEST_ROLE_LABEL, TEST_ROLE_LABEL_EDITED -class PermissionAPITestCase(APITestCase): +class PermissionAPITestCase(BaseAPITestCase): def setUp(self): super(PermissionAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( diff --git a/mayan/apps/rest_api/tests/__init__.py b/mayan/apps/rest_api/tests/__init__.py new file mode 100644 index 0000000000..0b7c12d02a --- /dev/null +++ b/mayan/apps/rest_api/tests/__init__.py @@ -0,0 +1 @@ +from .base import BaseAPITestCase # NOQA diff --git a/mayan/apps/rest_api/tests/base.py b/mayan/apps/rest_api/tests/base.py new file mode 100644 index 0000000000..098d83f9b9 --- /dev/null +++ b/mayan/apps/rest_api/tests/base.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, unicode_literals + +from rest_framework.test import APITestCase + +from permissions.classes import Permission +from smart_settings.classes import Namespace + + +class BaseAPITestCase(APITestCase): + """ + API test case class that invalidates permissions and smart settings + """ + + def setUp(self): + super(BaseAPITestCase, self).setUp() + Namespace.invalidate_cache_all() + Permission.invalidate_cache() diff --git a/mayan/apps/tags/tests/test_api.py b/mayan/apps/tags/tests/test_api.py index 454ecad870..d3aa157326 100644 --- a/mayan/apps/tags/tests/test_api.py +++ b/mayan/apps/tags/tests/test_api.py @@ -5,10 +5,9 @@ from django.core.urlresolvers import reverse from django.test import override_settings from django.utils.encoding import force_text -from rest_framework.test import APITestCase - from documents.models import DocumentType from documents.tests import TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH +from rest_api.tests import BaseAPITestCase from user_management.tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME ) @@ -22,12 +21,9 @@ from .literals import ( @override_settings(OCR_AUTO_OCR=False) -class TagAPITestCase(APITestCase): - """ - Test the tag API endpoints - """ - +class TagAPITestCase(BaseAPITestCase): def setUp(self): + super(TagAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -40,6 +36,7 @@ class TagAPITestCase(APITestCase): def tearDown(self): if hasattr(self, 'document_type'): self.document_type.delete() + super(TagAPITestCase, self).tearDown() def _create_tag(self): return Tag.objects.create(color=TEST_TAG_COLOR, label=TEST_TAG_LABEL) diff --git a/mayan/apps/user_management/tests/test_api.py b/mayan/apps/user_management/tests/test_api.py index d5cb0284f9..7aec08c631 100644 --- a/mayan/apps/user_management/tests/test_api.py +++ b/mayan/apps/user_management/tests/test_api.py @@ -4,7 +4,7 @@ from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.core.urlresolvers import reverse -from rest_framework.test import APITestCase +from rest_api.tests import BaseAPITestCase from ..tests.literals import ( TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME @@ -16,12 +16,10 @@ from .literals import ( ) -class UserManagementUserAPITestCase(APITestCase): - """ - Test the user API endpoints - """ - +class UserManagementUserAPITestCase(BaseAPITestCase): def setUp(self): + super(UserManagementUserAPITestCase, self).setUp() + self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -33,6 +31,7 @@ class UserManagementUserAPITestCase(APITestCase): def tearDown(self): get_user_model().objects.all().delete() + super(UserManagementUserAPITestCase, self).tearDown() def test_user_create(self): response = self.client.post( @@ -249,12 +248,9 @@ class UserManagementUserAPITestCase(APITestCase): self.assertEqual(group.user_set.first(), user) -class UserManagementGroupAPITestCase(APITestCase): - """ - Test the groups API endpoints - """ - +class UserManagementGroupAPITestCase(BaseAPITestCase): def setUp(self): + super(UserManagementGroupAPITestCase, self).setUp() self.admin_user = get_user_model().objects.create_superuser( username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD @@ -266,6 +262,7 @@ class UserManagementGroupAPITestCase(APITestCase): def tearDown(self): get_user_model().objects.all().delete() + super(UserManagementGroupAPITestCase, self).tearDown() def test_group_create(self): response = self.client.post(