summaryrefslogtreecommitdiff
path: root/tests/migrations/test_executor.py
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2014-11-19 19:43:12 -0700
committerCarl Meyer <carl@oddbird.net>2014-11-19 19:43:12 -0700
commit51f2de1530a49ef9c2f315025b47e107295cd38f (patch)
tree5deac5bc319e6239b3b719c6c57a8af4b8f7bf5a /tests/migrations/test_executor.py
parentd2bcb0598058dd93eac94bdbb7dd2565cff0abea (diff)
Added another migration-executor test to avoid regressions.
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
index 61da17b341..1bc1ca781d 100644
--- a/tests/migrations/test_executor.py
+++ b/tests/migrations/test_executor.py
@@ -325,3 +325,38 @@ class ExecutorUnitTests(TestCase):
should_be_rolled_back = [b2_impl, a4_impl, a2_impl, a3_impl]
exp = [(m, True) for m in should_be_rolled_back]
self.assertEqual(plan, exp)
+
+ def test_backwards_nothing_to_do(self):
+ """
+ If the current state satisfies the given target, do nothing.
+
+ a: 1 <--- 2
+ b: \- 1
+ c: \- 1
+
+ If a1 is applied already and a2 is not, and we're asked to migrate to
+ a1, don't apply or unapply b1 or c1, regardless of their current state.
+ """
+ a1_impl = FakeMigration('a1')
+ a1 = ('a', '1')
+ a2_impl = FakeMigration('a2')
+ a2 = ('a', '2')
+ b1_impl = FakeMigration('b1')
+ b1 = ('b', '1')
+ c1_impl = FakeMigration('c1')
+ c1 = ('c', '1')
+ graph = MigrationGraph()
+ graph.add_node(a1, a1_impl)
+ graph.add_node(a2, a2_impl)
+ graph.add_node(b1, b1_impl)
+ graph.add_node(c1, c1_impl)
+ graph.add_dependency(None, a2, a1)
+ graph.add_dependency(None, b1, a1)
+ graph.add_dependency(None, c1, a1)
+
+ executor = MigrationExecutor(None)
+ executor.loader = FakeLoader(graph, {a1, b1})
+
+ plan = executor.migration_plan({a1})
+
+ self.assertEqual(plan, [])