summaryrefslogtreecommitdiff
path: root/tests/fixtures_model_package
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-07-16 09:10:04 -0400
committerTim Graham <timograham@gmail.com>2013-07-24 06:56:33 -0400
commit31c13a99bb9ebdaf12ccab4e880c5da930d86e79 (patch)
treed7b2fcf5cbc526bf63ffe1a3b521ccc0e3f1d39c /tests/fixtures_model_package
parentc928725b933ff479c04e8a7fb74c4dc2ba138aa7 (diff)
downloaddjango-31c13a99bb9ebdaf12ccab4e880c5da930d86e79.tar.gz
Fixed #14300 -- Fixed initial SQL location if models is a package.
Thanks al_the_x for the report and fheinz for the draft patch.
Diffstat (limited to 'tests/fixtures_model_package')
-rw-r--r--tests/fixtures_model_package/models/sql/book.sql2
-rw-r--r--tests/fixtures_model_package/sql/book.sql1
-rw-r--r--tests/fixtures_model_package/tests.py17
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/fixtures_model_package/models/sql/book.sql b/tests/fixtures_model_package/models/sql/book.sql
new file mode 100644
index 0000000000..9b3918f4d7
--- /dev/null
+++ b/tests/fixtures_model_package/models/sql/book.sql
@@ -0,0 +1,2 @@
+-- Deprecated search path for custom SQL -- remove in Django 1.9
+INSERT INTO fixtures_model_package_book (name) VALUES ('My Deprecated Book');
diff --git a/tests/fixtures_model_package/sql/book.sql b/tests/fixtures_model_package/sql/book.sql
new file mode 100644
index 0000000000..21b1d9465b
--- /dev/null
+++ b/tests/fixtures_model_package/sql/book.sql
@@ -0,0 +1 @@
+INSERT INTO fixtures_model_package_book (name) VALUES ('My Book');
diff --git a/tests/fixtures_model_package/tests.py b/tests/fixtures_model_package/tests.py
index ad82267da3..1e22ac9833 100644
--- a/tests/fixtures_model_package/tests.py
+++ b/tests/fixtures_model_package/tests.py
@@ -5,6 +5,7 @@ import warnings
from django.core import management
from django.db import transaction
from django.test import TestCase, TransactionTestCase
+from django.utils.six import StringIO
from .models import Article, Book
@@ -110,3 +111,19 @@ class FixtureTestCase(TestCase):
],
lambda a: a.headline,
)
+
+
+class InitialSQLTests(TestCase):
+
+ def test_custom_sql(self):
+ """
+ #14300 -- Verify that custom_sql_for_model searches `app/sql` and not
+ `app/models/sql` (the old location will work until Django 1.9)
+ """
+ out = StringIO()
+ management.call_command("sqlcustom", "fixtures_model_package", stdout=out)
+ output = out.getvalue()
+ self.assertTrue("INSERT INTO fixtures_model_package_book (name) "
+ "VALUES ('My Book')" in output)
+ # value from deprecated search path models/sql (remove in Django 1.9)
+ self.assertTrue("Deprecated Book" in output)