diff --git a/polymorphic/tests.py b/polymorphic/tests.py index c9493fc..b14503e 100644 --- a/polymorphic/tests.py +++ b/polymorphic/tests.py @@ -67,45 +67,13 @@ class ModelX(Base): class ModelY(Base): field_y = models.CharField(max_length=10) -if django.VERSION[:2] > (1, 6): - class Enhance_Plain(models.Model): - field_p = models.CharField(max_length=10) - class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel): - base_id = models.AutoField(primary_key=True) - field_b = models.CharField(max_length=10) - class Enhance_Inherit(Enhance_Base, Enhance_Plain): - field_i = models.CharField(max_length=10) - - class DiamondBase(models.Model): - field_b = models.CharField(max_length=10) - class DiamondX(DiamondBase): - x_id = models.AutoField(primary_key=True) - field_x = models.CharField(max_length=10) - class DiamondY(DiamondBase): - y_id = models.AutoField(primary_key=True) - field_y = models.CharField(max_length=10) - class DiamondXY(DiamondBase): - xy_id = models.AutoField(primary_key=True) - field_x = models.CharField(max_length=10) - field_y = models.CharField(max_length=10) -else: - class Enhance_Plain(models.Model): - field_p = models.CharField(max_length=10) - class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel): - field_b = models.CharField(max_length=10) - class Enhance_Inherit(Enhance_Base, Enhance_Plain): - field_i = models.CharField(max_length=10) - - class DiamondBase(models.Model): - field_b = models.CharField(max_length=10) - class DiamondX(DiamondBase): - x_id = models.AutoField(primary_key=True) - field_x = models.CharField(max_length=10) - class DiamondY(DiamondBase): - y_id = models.AutoField(primary_key=True) - field_y = models.CharField(max_length=10) - class DiamondXY(DiamondX, DiamondY): - xy_id = models.AutoField(primary_key=True) +class Enhance_Plain(models.Model): + field_p = models.CharField(max_length=10) +class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel): + base_id = models.AutoField(primary_key=True) + field_b = models.CharField(max_length=10) +class Enhance_Inherit(Enhance_Base, Enhance_Plain): + field_i = models.CharField(max_length=10) class RelationBase(ShowFieldTypeAndContent, PolymorphicModel): field_base = models.CharField(max_length=10) @@ -294,21 +262,6 @@ class PolymorphicTests(TestCase): """ The test suite """ - def test_diamond_inheritance(self): - if django.VERSION[:2] > (1, 6): - print('') - print("# Django 1.7 doesn't allow multiple inheritance when two id fields exist. https://docs.djangoproject.com/en/dev/topics/db/models/#multiple-inheritance") - - # Django diamond problem - # https://code.djangoproject.com/ticket/10808 - o1 = DiamondXY.objects.create(field_b='b', field_x='x', field_y='y') - o2 = DiamondXY.objects.get() - - if o2.field_b != 'b': - print('') - print('# known django model inheritance diamond problem detected') - print('DiamondXY fields 1: field_b "{0}", field_x "{1}", field_y "{2}"'.format(o1.field_b, o1.field_x, o1.field_y)) - print('DiamondXY fields 2: field_b "{0}", field_x "{1}", field_y "{2}"'.format(o2.field_b, o2.field_x, o2.field_y)) def test_annotate_aggregate_order(self): # create a blog of type BlogA @@ -413,18 +366,14 @@ class PolymorphicTests(TestCase): , ]""" self.assertEqual(res, res_exp) - #if (a.pk!= uuid.UUID or c.pk!= uuid.UUID): - # print() - # print('# known inconstency with custom primary key field detected (django problem?)') a = UUIDPlainA.objects.create(field1='A1') b = UUIDPlainB.objects.create(field1='B1', field2='B2') c = UUIDPlainC.objects.create(field1='C1', field2='C2', field3='C3') qs = UUIDPlainA.objects.all() - if a.pk!= uuid.UUID or c.pk!= uuid.UUID: - print('') - print('# known type inconstency with custom primary key field detected (django problem?)') - + # Test that primary key values are valid UUIDs + self.assertEqual(uuid.UUID("urn:uuid:%s" % a.pk, version=1), a.pk) + self.assertEqual(uuid.UUID("urn:uuid:%s" % c.pk, version=1), c.pk) def create_model2abcd(self): """ @@ -683,13 +632,9 @@ class PolymorphicTests(TestCase): Enhance_Inherit.objects.create(field_b='b-inherit', field_p='p', field_i='i') qs = Enhance_Base.objects.all() - if django.VERSION[:2] > (1, 6): - self.assertEqual(repr(qs[0]), '') - self.assertEqual(repr(qs[1]), '') - else: - self.assertEqual(repr(qs[0]), '') - self.assertEqual(repr(qs[1]), '') self.assertEqual(len(qs), 2) + self.assertEqual(repr(qs[0]), '') + self.assertEqual(repr(qs[1]), '') def test_relation_base(self): # ForeignKey, ManyToManyField