'Tests the AlterModelTable operation.'

def test_alter_model_table(self):

    project_state = self.set_up_test_model('test_almota')
    operation = migrations.AlterModelTable('Pony', 'test_almota_pony_2')
    self.assertEqual(operation.describe(), 'Rename    table    for    Pony    to    test_almota_pony_2')
    new_state = project_state.clone()
    operation.state_forwards('test_almota', new_state)
    self.assertEqual(new_state.models[('test_almota', 'pony')].options['db_table'], 'test_almota_pony_2')
    self.assertTableExists('test_almota_pony')
    self.assertTableNotExists('test_almota_pony_2')
    with connection.schema_editor() as editor:
        operation.database_forwards('test_almota', editor, project_state, new_state)
    self.assertTableNotExists('test_almota_pony')
    self.assertTableExists('test_almota_pony_2')
    with connection.schema_editor() as editor:
        operation.database_backwards('test_almota', editor, new_state, project_state)
    self.assertTableExists('test_almota_pony')
    self.assertTableNotExists('test_almota_pony_2')
    definition = operation.deconstruct()
    self.assertEqual(definition[0], 'AlterModelTable')
    self.assertEqual(definition[1], [])
    self.assertEqual(definition[2], {'name': 'Pony', 'table': 'test_almota_pony_2'})
