mirror of
				https://github.com/django/django.git
				synced 2025-11-04 13:39:16 +00:00 
			
		
		
		
	Added another migration-executor test to avoid regressions.
This commit is contained in:
		
							parent
							
								
									d2bcb05980
								
							
						
					
					
						commit
						51f2de1530
					
				
					 1 changed files with 35 additions and 0 deletions
				
			
		| 
						 | 
					@ -325,3 +325,38 @@ class ExecutorUnitTests(TestCase):
 | 
				
			||||||
        should_be_rolled_back = [b2_impl, a4_impl, a2_impl, a3_impl]
 | 
					        should_be_rolled_back = [b2_impl, a4_impl, a2_impl, a3_impl]
 | 
				
			||||||
        exp = [(m, True) for m in should_be_rolled_back]
 | 
					        exp = [(m, True) for m in should_be_rolled_back]
 | 
				
			||||||
        self.assertEqual(plan, exp)
 | 
					        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, [])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue