summaryrefslogtreecommitdiff
path: root/tests/migrations/test_executor.py
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-05-30 18:08:58 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-05-30 18:08:58 +0100
commite6f7f4533c183800c2a9ac526d8ee8887e96ac5d (patch)
tree543a531e4aef284fccc65a5e6686a8a7a23d29e4 /tests/migrations/test_executor.py
parent7f9a0b7061e78a43b97abd6a3716d1e2017d72e3 (diff)
downloaddjango-e6f7f4533c183800c2a9ac526d8ee8887e96ac5d.tar.gz
Add an Executor for end-to-end running
Diffstat (limited to 'tests/migrations/test_executor.py')
-rw-r--r--tests/migrations/test_executor.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py
new file mode 100644
index 0000000000..629c47de56
--- /dev/null
+++ b/tests/migrations/test_executor.py
@@ -0,0 +1,35 @@
+from django.test import TransactionTestCase
+from django.db import connection
+from django.db.migrations.executor import MigrationExecutor
+
+
+class ExecutorTests(TransactionTestCase):
+ """
+ Tests the migration executor (full end-to-end running).
+
+ Bear in mind that if these are failing you should fix the other
+ test failures first, as they may be propagating into here.
+ """
+
+ def test_run(self):
+ """
+ Tests running a simple set of migrations.
+ """
+ executor = MigrationExecutor(connection)
+ # Let's look at the plan first and make sure it's up to scratch
+ plan = executor.migration_plan([("migrations", "0002_second")])
+ self.assertEqual(
+ plan,
+ [
+ (executor.loader.graph.nodes["migrations", "0001_initial"], False),
+ (executor.loader.graph.nodes["migrations", "0002_second"], False),
+ ],
+ )
+ # Were the tables there before?
+ self.assertNotIn("migrations_author", connection.introspection.get_table_list(connection.cursor()))
+ self.assertNotIn("migrations_book", connection.introspection.get_table_list(connection.cursor()))
+ # Alright, let's try running it
+ executor.migrate([("migrations", "0002_second")])
+ # Are the tables there now?
+ self.assertIn("migrations_author", connection.introspection.get_table_list(connection.cursor()))
+ self.assertIn("migrations_book", connection.introspection.get_table_list(connection.cursor()))