Merge pull request #120 from theatlantic-pr/cleanup-test-noise
Conflicts: polymorphic/tests.pyfix_request_path_info
commit
17c2445e39
|
|
@ -67,45 +67,13 @@ class ModelX(Base):
|
||||||
class ModelY(Base):
|
class ModelY(Base):
|
||||||
field_y = models.CharField(max_length=10)
|
field_y = models.CharField(max_length=10)
|
||||||
|
|
||||||
if django.VERSION[:2] > (1, 6):
|
class Enhance_Plain(models.Model):
|
||||||
class Enhance_Plain(models.Model):
|
field_p = models.CharField(max_length=10)
|
||||||
field_p = models.CharField(max_length=10)
|
class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel):
|
||||||
class Enhance_Base(ShowFieldTypeAndContent, PolymorphicModel):
|
base_id = models.AutoField(primary_key=True)
|
||||||
base_id = models.AutoField(primary_key=True)
|
field_b = models.CharField(max_length=10)
|
||||||
field_b = models.CharField(max_length=10)
|
class Enhance_Inherit(Enhance_Base, Enhance_Plain):
|
||||||
class Enhance_Inherit(Enhance_Base, Enhance_Plain):
|
field_i = models.CharField(max_length=10)
|
||||||
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 RelationBase(ShowFieldTypeAndContent, PolymorphicModel):
|
class RelationBase(ShowFieldTypeAndContent, PolymorphicModel):
|
||||||
field_base = models.CharField(max_length=10)
|
field_base = models.CharField(max_length=10)
|
||||||
|
|
@ -294,21 +262,6 @@ class PolymorphicTests(TestCase):
|
||||||
"""
|
"""
|
||||||
The test suite
|
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):
|
def test_annotate_aggregate_order(self):
|
||||||
# create a blog of type BlogA
|
# create a blog of type BlogA
|
||||||
|
|
@ -413,18 +366,14 @@ class PolymorphicTests(TestCase):
|
||||||
<UUIDArtProject: uuid_primary_key (UUIDField/pk), topic (CharField) "Sculpting with Tim", artist (CharField) "T. Turner">,
|
<UUIDArtProject: uuid_primary_key (UUIDField/pk), topic (CharField) "Sculpting with Tim", artist (CharField) "T. Turner">,
|
||||||
<UUIDResearchProject: uuid_primary_key (UUIDField/pk), topic (CharField) "Swallow Aerodynamics", supervisor (CharField) "Dr. Winter"> ]"""
|
<UUIDResearchProject: uuid_primary_key (UUIDField/pk), topic (CharField) "Swallow Aerodynamics", supervisor (CharField) "Dr. Winter"> ]"""
|
||||||
self.assertEqual(res, res_exp)
|
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')
|
a = UUIDPlainA.objects.create(field1='A1')
|
||||||
b = UUIDPlainB.objects.create(field1='B1', field2='B2')
|
b = UUIDPlainB.objects.create(field1='B1', field2='B2')
|
||||||
c = UUIDPlainC.objects.create(field1='C1', field2='C2', field3='C3')
|
c = UUIDPlainC.objects.create(field1='C1', field2='C2', field3='C3')
|
||||||
qs = UUIDPlainA.objects.all()
|
qs = UUIDPlainA.objects.all()
|
||||||
if a.pk!= uuid.UUID or c.pk!= uuid.UUID:
|
# Test that primary key values are valid UUIDs
|
||||||
print('')
|
self.assertEqual(uuid.UUID("urn:uuid:%s" % a.pk, version=1), a.pk)
|
||||||
print('# known type inconstency with custom primary key field detected (django problem?)')
|
self.assertEqual(uuid.UUID("urn:uuid:%s" % c.pk, version=1), c.pk)
|
||||||
|
|
||||||
|
|
||||||
def create_model2abcd(self):
|
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')
|
Enhance_Inherit.objects.create(field_b='b-inherit', field_p='p', field_i='i')
|
||||||
|
|
||||||
qs = Enhance_Base.objects.all()
|
qs = Enhance_Base.objects.all()
|
||||||
if django.VERSION[:2] > (1, 6):
|
|
||||||
self.assertEqual(repr(qs[0]), '<Enhance_Base: base_id (AutoField/pk) 1, field_b (CharField) "b-base">')
|
|
||||||
self.assertEqual(repr(qs[1]), '<Enhance_Inherit: base_id (AutoField/pk) 2, field_b (CharField) "b-inherit", id 1, field_p (CharField) "p", field_i (CharField) "i">')
|
|
||||||
else:
|
|
||||||
self.assertEqual(repr(qs[0]), '<Enhance_Base: id 1, field_b (CharField) "b-base">')
|
|
||||||
self.assertEqual(repr(qs[1]), '<Enhance_Inherit: id 2, field_b (CharField) "b-inherit", field_p (CharField) "p", field_i (CharField) "i">')
|
|
||||||
self.assertEqual(len(qs), 2)
|
self.assertEqual(len(qs), 2)
|
||||||
|
self.assertEqual(repr(qs[0]), '<Enhance_Base: base_id (AutoField/pk) 1, field_b (CharField) "b-base">')
|
||||||
|
self.assertEqual(repr(qs[1]), '<Enhance_Inherit: base_id (AutoField/pk) 2, field_b (CharField) "b-inherit", id 1, field_p (CharField) "p", field_i (CharField) "i">')
|
||||||
|
|
||||||
def test_relation_base(self):
|
def test_relation_base(self):
|
||||||
# ForeignKey, ManyToManyField
|
# ForeignKey, ManyToManyField
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue