'Tests loading a complex set of squashed migrations'

@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_squashed_complex'})
def test_loading_squashed_complex(self):

    loader = MigrationLoader(connection)
    recorder = MigrationRecorder(connection)
    self.addCleanup(recorder.flush)
    def num_nodes():
        plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
        return len((plan - loader.applied_migrations))
    loader.build_graph()
    self.assertEqual(num_nodes(), 5)
    recorder.record_applied('migrations', '1_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 4)
    recorder.record_applied('migrations', '2_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 3)
    recorder.record_applied('migrations', '3_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 4)
    recorder.record_applied('migrations', '4_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 3)
    recorder.record_applied('migrations', '5_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 2)
    recorder.record_applied('migrations', '6_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 1)
    recorder.record_applied('migrations', '7_auto')
    loader.build_graph()
    self.assertEqual(num_nodes(), 0)
