Add BaseAPITestCase class that invalidates the permission and smart settings caches.
Use BaseAPITestCase for all API test cases.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
1
mayan/apps/rest_api/tests/__init__.py
Normal file
1
mayan/apps/rest_api/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .base import BaseAPITestCase # NOQA
|
||||
17
mayan/apps/rest_api/tests/base.py
Normal file
17
mayan/apps/rest_api/tests/base.py
Normal file
@@ -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()
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user