Add test mixin to convert instances to dicts

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-05-10 19:30:33 -04:00
parent f6696771f9
commit 7cf8cd2f28
2 changed files with 21 additions and 5 deletions

View File

@@ -10,13 +10,19 @@ from mayan.apps.smart_settings.classes import Namespace
from .mixins import ( from .mixins import (
ClientMethodsTestCaseMixin, ContentTypeCheckTestCaseMixin, ClientMethodsTestCaseMixin, ContentTypeCheckTestCaseMixin,
DatabaseConversionMixin, OpenFileCheckTestCaseMixin, DatabaseConversionMixin, ModelTestCaseMixin,
RandomPrimaryKeyModelMonkeyPatchMixin, SilenceLoggerTestCaseMixin, OpenFileCheckTestCaseMixin, RandomPrimaryKeyModelMonkeyPatchMixin,
TempfileCheckTestCasekMixin, TestViewTestCaseMixin SilenceLoggerTestCaseMixin, TempfileCheckTestCasekMixin,
TestViewTestCaseMixin
) )
class BaseTestCase(SilenceLoggerTestCaseMixin, RandomPrimaryKeyModelMonkeyPatchMixin, DatabaseConversionMixin, ACLTestCaseMixin, OpenFileCheckTestCaseMixin, TempfileCheckTestCasekMixin, TestCase): class BaseTestCase(
SilenceLoggerTestCaseMixin, RandomPrimaryKeyModelMonkeyPatchMixin,
DatabaseConversionMixin, ACLTestCaseMixin,
ModelTestCaseMixin, OpenFileCheckTestCaseMixin,
TempfileCheckTestCasekMixin, TestCase
):
""" """
This is the most basic test case class any test in the project should use. This is the most basic test case class any test in the project should use.
""" """
@@ -28,7 +34,10 @@ class BaseTestCase(SilenceLoggerTestCaseMixin, RandomPrimaryKeyModelMonkeyPatchM
Permission.invalidate_cache() Permission.invalidate_cache()
class GenericViewTestCase(ClientMethodsTestCaseMixin, ContentTypeCheckTestCaseMixin, TestViewTestCaseMixin, BaseTestCase): class GenericViewTestCase(
ClientMethodsTestCaseMixin, ContentTypeCheckTestCaseMixin,
TestViewTestCaseMixin, BaseTestCase
):
""" """
A generic view test case built on top of the base test case providing A generic view test case built on top of the base test case providing
a single, user customizable view to test object resolution and shorthand a single, user customizable view to test object resolution and shorthand

View File

@@ -113,6 +113,13 @@ class DatabaseConversionMixin(object):
) )
class ModelTestCaseMixin(object):
def _model_instance_to_dictionary(self, instance):
return instance._meta.model._default_manager.filter(
pk=instance.pk
).values()[0]
class OpenFileCheckTestCaseMixin(object): class OpenFileCheckTestCaseMixin(object):
def _get_descriptor_count(self): def _get_descriptor_count(self):
process = psutil.Process() process = psutil.Process()