From 3bd849062c57d297f3b6f7cb12e4644ce19c52f8 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Thu, 17 Dec 2009 21:54:37 +0000 Subject: [PATCH] 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 --- .../fixtures_regress/models.py | 91 +++++++++---------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py index 6e733ec256..7aa66a6f6a 100644 --- a/tests/regressiontests/fixtures_regress/models.py +++ b/tests/regressiontests/fixtures_regress/models.py @@ -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 () [{"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 () >>> 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 () # 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.