summaryrefslogtreecommitdiff
path: root/tests/commands_sql_migrations/tests.py
diff options
context:
space:
mode:
authorVíðir Valberg Guðmundsson <valberg@orn.li>2014-05-29 23:03:10 +0200
committerAndrew Godwin <andrew@aeracode.org>2014-05-29 15:36:30 -0700
commitb6a960cd1df4a191fc2900bcaa76c73f2696fc4d (patch)
tree2c9274417fbb54a8230cf590bf4fd77fcc97b710 /tests/commands_sql_migrations/tests.py
parentc5afdc3d73945c8e9d45442dd488f413e67ce2aa (diff)
[1.7.x] Making SQL management commands migration aware.
Diffstat (limited to 'tests/commands_sql_migrations/tests.py')
-rw-r--r--tests/commands_sql_migrations/tests.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/commands_sql_migrations/tests.py b/tests/commands_sql_migrations/tests.py
new file mode 100644
index 0000000000..9d914c0149
--- /dev/null
+++ b/tests/commands_sql_migrations/tests.py
@@ -0,0 +1,39 @@
+from __future__ import unicode_literals
+
+from django.apps import apps
+from django.core.management import CommandError
+from django.core.management.color import no_style
+from django.core.management.sql import (sql_create, sql_delete, sql_indexes,
+ sql_destroy_indexes, sql_all)
+from django.db import connections, DEFAULT_DB_ALIAS, router
+from django.test import TestCase
+
+
+class SQLCommandsMigrationsTestCase(TestCase):
+ """Tests that apps with migrations can not use sql commands."""
+
+ def test_sql_create(self):
+ app_config = apps.get_app_config('commands_sql_migrations')
+ with self.assertRaises(CommandError):
+ sql_create(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
+
+ def test_sql_delete(self):
+ app_config = apps.get_app_config('commands_sql_migrations')
+ with self.assertRaises(CommandError):
+ sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
+
+ def test_sql_indexes(self):
+ app_config = apps.get_app_config('commands_sql_migrations')
+ with self.assertRaises(CommandError):
+ sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
+
+ def test_sql_destroy_indexes(self):
+ app_config = apps.get_app_config('commands_sql_migrations')
+ with self.assertRaises(CommandError):
+ sql_destroy_indexes(app_config, no_style(),
+ connections[DEFAULT_DB_ALIAS])
+
+ def test_sql_all(self):
+ app_config = apps.get_app_config('commands_sql_migrations')
+ with self.assertRaises(CommandError):
+ sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])