summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2012-01-14 17:26:32 +0000
committerLuke Plant <L.Plant.98@cantab.net>2012-01-14 17:26:32 +0000
commit4e29b70b9dfb836a6ece537728f1ad9702786948 (patch)
tree3f2262bfa20fe3b9a006c4f828d3cc9b482cd0c0 /tests
parent64229eb3882be7080f73bc4559f44dc34507b140 (diff)
Fixed #17530 - Fixture loading with deferred constraints broken for Postgres for fixtures from multiple dirs/files
Thanks to claudep for the review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17372 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/fixtures_regress/fixtures_1/forward_ref_1.json10
-rw-r--r--tests/regressiontests/fixtures_regress/fixtures_2/forward_ref_2.json9
-rw-r--r--tests/regressiontests/fixtures_regress/tests.py20
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/regressiontests/fixtures_regress/fixtures_1/forward_ref_1.json b/tests/regressiontests/fixtures_regress/fixtures_1/forward_ref_1.json
new file mode 100644
index 0000000000..1a75037b48
--- /dev/null
+++ b/tests/regressiontests/fixtures_regress/fixtures_1/forward_ref_1.json
@@ -0,0 +1,10 @@
+[
+ {
+ "pk": 1,
+ "model": "fixtures_regress.book",
+ "fields": {
+ "name": "Cryptonomicon",
+ "author": 4
+ }
+ }
+]
diff --git a/tests/regressiontests/fixtures_regress/fixtures_2/forward_ref_2.json b/tests/regressiontests/fixtures_regress/fixtures_2/forward_ref_2.json
new file mode 100644
index 0000000000..9cb63085a4
--- /dev/null
+++ b/tests/regressiontests/fixtures_regress/fixtures_2/forward_ref_2.json
@@ -0,0 +1,9 @@
+[
+ {
+ "pk": "4",
+ "model": "fixtures_regress.person",
+ "fields": {
+ "name": "Neal Stephenson"
+ }
+ }
+]
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 5b8dc6659f..ed8b404788 100644
--- a/tests/regressiontests/fixtures_regress/tests.py
+++ b/tests/regressiontests/fixtures_regress/tests.py
@@ -16,6 +16,7 @@ from django.db import transaction
from django.db.models import signals
from django.test import (TestCase, TransactionTestCase, skipIfDBFeature,
skipUnlessDBFeature)
+from django.test.utils import override_settings
from .models import (Animal, Stuff, Absolute, Parent, Child, Article, Widget,
Store, Person, Book, NKChild, RefToNKChild, Circle1, Circle2, Circle3,
@@ -390,6 +391,25 @@ class TestFixtures(TestCase):
stderr.getvalue().startswith('Problem installing fixture')
)
+ _cur_dir = os.path.dirname(os.path.abspath(__file__))
+
+ @override_settings(FIXTURE_DIRS=[os.path.join(_cur_dir, 'fixtures_1'),
+ os.path.join(_cur_dir, 'fixtures_2')])
+ def test_loaddata_forward_refs_split_fixtures(self):
+ """
+ Regression for #17530 - should be able to cope with forward references
+ when the fixtures are not in the same files or directories.
+ """
+ management.call_command(
+ 'loaddata',
+ 'forward_ref_1.json',
+ 'forward_ref_2.json',
+ verbosity=0,
+ commit=False
+ )
+ self.assertEqual(Book.objects.all()[0].id, 1)
+ self.assertEqual(Person.objects.all()[0].id, 4)
+
def test_loaddata_no_fixture_specified(self):
"""
Regression for #7043 - Error is quickly reported when no fixtures is provided in the command line.