'Test creation of new model with indexes already defined.'

def test_create_model_with_indexes(self):

    author = ModelState('otherapp', 'Author', [('id', models.AutoField(primary_key=True)), ('name', models.CharField(max_length=200))], {'indexes': [models.Index(fields=['name'], name='create_model_with_indexes_idx')]})
    changes = self.get_changes([], [author])
    added_index = models.Index(fields=['name'], name='create_model_with_indexes_idx')
    self.assertEqual(len(changes['otherapp']), 1)
    migration = changes['otherapp'][0]
    self.assertEqual(len(migration.operations), 2)
    self.assertOperationTypes(changes, 'otherapp', 0, ['CreateModel', 'AddIndex'])
    self.assertOperationAttributes(changes, 'otherapp', 0, 0, name='Author')
    self.assertOperationAttributes(changes, 'otherapp', 0, 1, model_name='author', index=added_index)
