[1.9.x] Refs #25745 -- Isolated a foreign_object test.

Backport of 2eefbca1a4 from master
This commit is contained in:
Simon Charette 2015-11-11 23:55:08 -05:00
parent e8512811cd
commit fb016e6c55
1 changed files with 13 additions and 0 deletions

View File

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