1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

Fixed #12395 - fixed test suite flushing problems on Postgres, MySQL.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11900 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2009-12-17 21:54:37 +00:00
parent fed3081caf
commit 3bd849062c

View File

@ -129,6 +129,49 @@ class Book(models.Model):
', '.join(s.name for s in self.stores.all())
)
# ome models with pathological circular dependencies
class Circle1(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.circle2']
class Circle2(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.circle1']
class Circle3(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.circle3']
class Circle4(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.circle5']
class Circle5(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.circle6']
class Circle6(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.circle4']
class ExternalDependency(models.Model):
name = models.CharField(max_length=255)
def natural_key(self):
return self.name
natural_key.dependencies = ['fixtures_regress.book']
__test__ = {'API_TESTS':"""
>>> from django.core import management
@ -235,8 +278,7 @@ Weight = 1.2 (<type 'float'>)
[{"pk": 1, "model": "fixtures_regress.animal", "fields": {"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}, {"pk": 2, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 2.29..., "name": "Platypus", "latin_name": "Ornithorhynchus anatinus"}}, {"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}]
###############################################
# Regression for #11428 - Proxy models aren't included
# when you run dumpdata over an entire app
# Regression for #11428 - Proxy models aren't included when you dumpdata
# Flush out the database first
>>> management.call_command('reset', 'fixtures_regress', interactive=False, verbosity=0)
@ -245,7 +287,7 @@ Weight = 1.2 (<type 'float'>)
>>> Widget(name='grommet').save()
# Dump data for the entire app. The proxy class shouldn't be included
>>> management.call_command('dumpdata', 'fixtures_regress', format='json')
>>> management.call_command('dumpdata', 'fixtures_regress.widget', 'fixtures_regress.widgetproxy', format='json')
[{"pk": 1, "model": "fixtures_regress.widget", "fields": {"name": "grommet"}}]
###############################################
@ -258,49 +300,6 @@ Weight = 1.2 (<type 'float'>)
# Now lets check the dependency sorting explicitly
# First Some models with pathological circular dependencies
>>> class Circle1(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.circle2']
>>> class Circle2(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.circle1']
>>> class Circle3(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.circle3']
>>> class Circle4(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.circle5']
>>> class Circle5(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.circle6']
>>> class Circle6(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.circle4']
>>> class ExternalDependency(models.Model):
... name = models.CharField(max_length=255)
... def natural_key(self):
... return self.name
... natural_key.dependencies = ['fixtures_regress.book']
# It doesn't matter what order you mention the models
# Store *must* be serialized before then Person, and both
# must be serialized before Book.