'Test errors thrown when creating or deleting aliases.'

def testCreateDeleteAliases(self):

    self.assertTrue(('acknowledged' in self.conn.indices.create_index(self.index_name)))
    result = self.conn.indices.get_indices(include_aliases=True)
    self.assertTrue(('test-index' in result))
    self.assertEqual(result['test-index'], {'num_docs': 0})
    self.assertTrue(('test-alias' not in result))
    err = self.checkRaises(exceptions.IndexMissingException, self.conn.indices.get_alias, 'test-alias')
    self.assertEqual(str(err), '[test-alias]    missing')
    self.conn.indices.delete_alias('test-alias', self.index_name)
    self.conn.indices.change_aliases([['add', 'test-index', 'test-alias', {}]])
    self.assertEqual(self.conn.indices.get_alias('test-alias'), ['test-index'])
    err = self.checkRaises(exceptions.IndexMissingException, self.conn.indices.change_aliases, [['add', 'test-missing-index', 'test-alias', {}]])
    self.assertEqual(str(err), '[test-missing-index]    missing')
    self.assertEqual(self.conn.indices.get_alias('test-alias'), ['test-index'])
    result = self.conn.indices.get_indices(include_aliases=True)
    self.assertTrue(('test-index' in result))
    self.assertEqual(result['test-index'], {'num_docs': 0})
    self.assertTrue(('test-alias' in result))
    self.assertEqual(result['test-alias'], {'alias_for': ['test-index'], 'num_docs': 0})
    result = self.conn.indices.get_indices(include_aliases=False)
    self.assertTrue(('test-index' in result))
    self.assertEqual(result['test-index'], {'num_docs': 0})
    self.assertTrue(('test-alias' not in result))
    self.assertTrue(('ok' in self.conn.indices.create_index('test-index2')))
    self.conn.indices.change_aliases([['add', 'test-index2', 'test-alias', {}]])
    self.assertEqual(sorted(self.conn.indices.get_alias('test-alias')), ['test-index', 'test-index2'])
    self.conn.indices.delete_alias('test-alias', [self.index_name, 'test-index2'])
    self.checkRaises(exceptions.IndexMissingException, self.conn.indices.get_alias, 'test-alias')
    self.conn.indices.delete_alias('test-alias', [self.index_name, 'test-index2'])
    err = self.checkRaises(exceptions.IndexMissingException, self.conn.indices.get_alias, 'test-alias')
    self.assertEqual(str(err), '[test-alias]    missing')
