mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-21 22:10:25 +00:00
21 lines
793 B
Python
21 lines
793 B
Python
from django.test import TestCase
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
from model_utils.tests.models import InheritParent, InheritChild
|
|
|
|
class InheritanceCastModelTests(TestCase):
|
|
def setUp(self):
|
|
self.parent = InheritParent.objects.create()
|
|
self.child = InheritChild.objects.create()
|
|
|
|
def testParentRealType(self):
|
|
self.assertEquals(self.parent.real_type,
|
|
ContentType.objects.get_for_model(InheritParent))
|
|
|
|
def testChildRealType(self):
|
|
self.assertEquals(self.child.real_type,
|
|
ContentType.objects.get_for_model(InheritChild))
|
|
|
|
def testCast(self):
|
|
obj = InheritParent.objects.get(pk=self.child.pk).cast()
|
|
self.assertEquals(obj.__class__, InheritChild)
|