mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Add an Executor for end-to-end running
This commit is contained in:
parent
7f9a0b7061
commit
e6f7f4533c
7 changed files with 188 additions and 11 deletions
35
tests/migrations/test_executor.py
Normal file
35
tests/migrations/test_executor.py
Normal file
|
@ -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()))
|
Loading…
Add table
Add a link
Reference in a new issue