mirror of
https://github.com/django/django.git
synced 2025-08-30 15:27:40 +00:00
Fixed #24129 -- Added indicator that migrations are rendering the initial state
Thanks Tim Graham for the review.
This commit is contained in:
parent
9f51d0c86d
commit
eeb88123e7
3 changed files with 59 additions and 2 deletions
|
@ -150,7 +150,7 @@ class ExecutorTests(MigrationTestBase):
|
|||
"""
|
||||
state = {"faked": None}
|
||||
|
||||
def fake_storer(phase, migration, fake):
|
||||
def fake_storer(phase, migration=None, fake=None):
|
||||
state["faked"] = fake
|
||||
executor = MigrationExecutor(connection, progress_callback=fake_storer)
|
||||
# Were the tables there before?
|
||||
|
@ -323,6 +323,51 @@ class ExecutorTests(MigrationTestBase):
|
|||
self.assertTableNotExists("lookuperror_b_b1")
|
||||
self.assertTableNotExists("lookuperror_c_c1")
|
||||
|
||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
|
||||
def test_process_callback(self):
|
||||
"""
|
||||
#24129 - Tests callback process
|
||||
"""
|
||||
call_args_list = []
|
||||
|
||||
def callback(*args):
|
||||
call_args_list.append(args)
|
||||
|
||||
executor = MigrationExecutor(connection, progress_callback=callback)
|
||||
# Were the tables there before?
|
||||
self.assertTableNotExists("migrations_author")
|
||||
self.assertTableNotExists("migrations_tribble")
|
||||
executor.migrate([
|
||||
("migrations", "0001_initial"),
|
||||
("migrations", "0002_second"),
|
||||
])
|
||||
# Rebuild the graph to reflect the new DB state
|
||||
executor.loader.build_graph()
|
||||
|
||||
executor.migrate([
|
||||
("migrations", None),
|
||||
("migrations", None),
|
||||
])
|
||||
self.assertTableNotExists("migrations_author")
|
||||
self.assertTableNotExists("migrations_tribble")
|
||||
|
||||
migrations = executor.loader.graph.nodes
|
||||
expected = [
|
||||
("render_start", ),
|
||||
("render_success", ),
|
||||
("apply_start", migrations['migrations', '0001_initial'], False),
|
||||
("apply_success", migrations['migrations', '0001_initial'], False),
|
||||
("apply_start", migrations['migrations', '0002_second'], False),
|
||||
("apply_success", migrations['migrations', '0002_second'], False),
|
||||
("render_start", ),
|
||||
("render_success", ),
|
||||
("unapply_start", migrations['migrations', '0002_second'], False),
|
||||
("unapply_success", migrations['migrations', '0002_second'], False),
|
||||
("unapply_start", migrations['migrations', '0001_initial'], False),
|
||||
("unapply_success", migrations['migrations', '0001_initial'], False),
|
||||
]
|
||||
self.assertEqual(call_args_list, expected)
|
||||
|
||||
|
||||
class FakeLoader(object):
|
||||
def __init__(self, graph, applied):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue