Add test mixin to test the db conversion (dumping and loading) of a specific app.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-09-21 00:11:17 -04:00
parent 9e4ad9a64f
commit 5d24521049
2 changed files with 11 additions and 2 deletions

View File

@@ -19,11 +19,12 @@ from user_management.tests import (
from .literals import TEST_VIEW_NAME, TEST_VIEW_URL
from .mixins import (
ContentTypeCheckMixin, OpenFileCheckMixin, TempfileCheckMixin, UserMixin
ContentTypeCheckMixin, DatabaseConversionMixin, OpenFileCheckMixin,
TempfileCheckMixin, UserMixin
)
class BaseTestCase(UserMixin, ContentTypeCheckMixin, OpenFileCheckMixin, TempfileCheckMixin, TestCase):
class BaseTestCase(DatabaseConversionMixin, UserMixin, ContentTypeCheckMixin, OpenFileCheckMixin, TempfileCheckMixin, TestCase):
"""
This is the most basic test case class any test in the project should use.
"""

View File

@@ -6,6 +6,7 @@ import os
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.core import management
if getattr(settings, 'COMMON_TEST_FILE_HANDLES', False):
import psutil
@@ -45,6 +46,13 @@ class ContentTypeCheckMixin(object):
self.client = CustomClient()
class DatabaseConversionMixin(object):
def _test_database_conversion(self, *app_labels):
management.call_command(
'convertdb', *app_labels
)
class OpenFileCheckMixin(object):
def _get_descriptor_count(self):
process = psutil.Process()