Loading tests/foreign_object/tests.py +13 −0 Original line number Diff line number Diff line import datetime from operator import attrgetter from django.apps.registry import Apps from django.core.exceptions import FieldError from django.db import models from django.db.models.fields.related import ForeignObject Loading Loading @@ -398,11 +399,14 @@ class MultiColumnFKTests(TestCase): class TestModelCheckTests(SimpleTestCase): def test_check_composite_foreign_object(self): test_apps = Apps(['foreign_object']) class Parent(models.Model): a = models.PositiveIntegerField() b = models.PositiveIntegerField() class Meta: apps = test_apps unique_together = (('a', 'b'),) class Child(models.Model): Loading @@ -417,15 +421,21 @@ class TestModelCheckTests(SimpleTestCase): related_name='children', ) class Meta: apps = test_apps self.assertEqual(Child._meta.get_field('parent').check(from_model=Child), []) def test_check_subset_composite_foreign_object(self): test_apps = Apps(['foreign_object']) class Parent(models.Model): a = models.PositiveIntegerField() b = models.PositiveIntegerField() c = models.PositiveIntegerField() class Meta: apps = test_apps unique_together = (('a', 'b'),) class Child(models.Model): Loading @@ -441,4 +451,7 @@ class TestModelCheckTests(SimpleTestCase): related_name='children', ) class Meta: apps = test_apps self.assertEqual(Child._meta.get_field('parent').check(from_model=Child), []) Loading
tests/foreign_object/tests.py +13 −0 Original line number Diff line number Diff line import datetime from operator import attrgetter from django.apps.registry import Apps from django.core.exceptions import FieldError from django.db import models from django.db.models.fields.related import ForeignObject Loading Loading @@ -398,11 +399,14 @@ class MultiColumnFKTests(TestCase): class TestModelCheckTests(SimpleTestCase): def test_check_composite_foreign_object(self): test_apps = Apps(['foreign_object']) class Parent(models.Model): a = models.PositiveIntegerField() b = models.PositiveIntegerField() class Meta: apps = test_apps unique_together = (('a', 'b'),) class Child(models.Model): Loading @@ -417,15 +421,21 @@ class TestModelCheckTests(SimpleTestCase): related_name='children', ) class Meta: apps = test_apps self.assertEqual(Child._meta.get_field('parent').check(from_model=Child), []) def test_check_subset_composite_foreign_object(self): test_apps = Apps(['foreign_object']) class Parent(models.Model): a = models.PositiveIntegerField() b = models.PositiveIntegerField() c = models.PositiveIntegerField() class Meta: apps = test_apps unique_together = (('a', 'b'),) class Child(models.Model): Loading @@ -441,4 +451,7 @@ class TestModelCheckTests(SimpleTestCase): related_name='children', ) class Meta: apps = test_apps self.assertEqual(Child._meta.get_field('parent').check(from_model=Child), [])