def test_get_aliased_index_multiple_indices(self, conn): """Raise if ``index`` is an alias pointing to multiple indices.""" conn.indices.get_alias.return_value = { 'index-one': {'aliases': {'foo': {}}}, 'index-two': {'aliases': {'foo': {}}}, } client = Client('localhost', 'foo') with pytest.raises(RuntimeError): client.get_aliased_index()
def test_get_aliased_index(self, conn): """If ``index`` is an alias, return the name of the concrete index.""" conn.indices.get_alias.return_value = { 'target-index': {'aliases': {'foo': {}}}, } client = Client('localhost', 'foo') assert client.get_aliased_index() == 'target-index'
def test_get_aliased_index_no_alias(self, conn): """If ``index`` is a concrete index, return None.""" conn.indices.get_alias.side_effect = NotFoundError('test', 'test desc') client = Client('localhost', 'foo') assert client.get_aliased_index() is None