django-model-utils/model_utils/tests/tests.py
Carl Meyer 3247ac5d4b initial import (with InheritanceCastModel)
--HG--
extra : convert_revision : carl%40dirtcircle.com-20090702180302-idhig8pzmbv8nv7l
2009-07-02 14:03:02 -04:00

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)