diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-08-12 18:30:38 +0700 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-08-13 15:14:11 +0300 |
| commit | 163a34ce4bc1086b346a52c7271f48d2c207f710 (patch) | |
| tree | 814802dc18e774cdfd3ef64b6b6c6aac8c637e4c /tests | |
| parent | dcdc579d162b750ee3449e34efd772703592faca (diff) | |
Fixed #20883 -- Made model inheritance find parent links in abstract parents
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/model_inheritance_regress/models.py | 13 | ||||
| -rw-r--r-- | tests/model_inheritance_regress/tests.py | 16 |
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/model_inheritance_regress/models.py b/tests/model_inheritance_regress/models.py index 811c8175bb..0f45a2cb3f 100644 --- a/tests/model_inheritance_regress/models.py +++ b/tests/model_inheritance_regress/models.py @@ -50,6 +50,19 @@ class ParkingLot3(Place): primary_key = models.AutoField(primary_key=True) parent = models.OneToOneField(Place, parent_link=True) +class ParkingLot4(models.Model): + # Test parent_link connector can be discovered in abstract classes. + parent = models.OneToOneField(Place, parent_link=True) + + class Meta: + abstract = True + +class ParkingLot4A(ParkingLot4, Place): + pass + +class ParkingLot4B(Place, ParkingLot4): + pass + class Supplier(models.Model): restaurant = models.ForeignKey(Restaurant) diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py index 10a1230685..7f78fc7a98 100644 --- a/tests/model_inheritance_regress/tests.py +++ b/tests/model_inheritance_regress/tests.py @@ -14,7 +14,8 @@ from .models import (Place, Restaurant, ItalianRestaurant, ParkingLot, ParkingLot2, ParkingLot3, Supplier, Wholesaler, Child, SelfRefParent, SelfRefChild, ArticleWithAuthor, M2MChild, QualityControl, DerivedM, Person, BirthdayParty, BachelorParty, MessyBachelorParty, - InternalCertificationAudit, BusStation, TrainStation, User, Profile) + InternalCertificationAudit, BusStation, TrainStation, User, Profile, + ParkingLot4A, ParkingLot4B) class ModelInheritanceTest(TestCase): @@ -311,6 +312,19 @@ class ModelInheritanceTest(TestCase): ParkingLot3._meta.get_ancestor_link(Place).name, "parent") + def test_use_explicit_o2o_to_parent_from_abstract_model(self): + self.assertEqual(ParkingLot4A._meta.pk.name, "parent") + ParkingLot4A.objects.create( + name="Parking4A", + address='21 Jump Street', + ) + + self.assertEqual(ParkingLot4B._meta.pk.name, "parent") + ParkingLot4A.objects.create( + name="Parking4B", + address='21 Jump Street', + ) + def test_all_fields_from_abstract_base_class(self): """ Regression tests for #7588 |
