'Tests auto-naming of migrations for graph matching.'

def test_arrange_for_graph(self):

    graph = MigrationGraph()
    graph.add_node(('testapp', '0001_initial'), None)
    graph.add_node(('testapp', '0002_foobar'), None)
    graph.add_node(('otherapp', '0001_initial'), None)
    graph.add_dependency('testapp.0002_foobar', ('testapp', '0002_foobar'), ('testapp', '0001_initial'))
    graph.add_dependency('testapp.0002_foobar', ('testapp', '0002_foobar'), ('otherapp', '0001_initial'))
    before = self.make_project_state([])
    after = self.make_project_state([self.author_empty, self.other_pony, self.other_stable])
    autodetector = MigrationAutodetector(before, after)
    changes = autodetector._detect_changes()
    changes = autodetector.arrange_for_graph(changes, graph)
    self.assertEqual(changes['testapp'][0].name, '0003_author')
    self.assertEqual(changes['testapp'][0].dependencies, [('testapp', '0002_foobar')])
    self.assertEqual(changes['otherapp'][0].name, '0002_pony_stable')
    self.assertEqual(changes['otherapp'][0].dependencies, [('otherapp', '0001_initial')])
