Coverage for /Users/buh/.pyenv/versions/3.12.2/envs/es-testbed/lib/python3.12/site-packages/es_testbed/classes/entities/alias.py: 86%
23 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-24 22:41 -0600
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-24 22:41 -0600
1"""Alias Entity Class"""
2import typing as t
3from elasticsearch8 import Elasticsearch
4from es_testbed.helpers.utils import getlogger
5from es_testbed.helpers import es_api
6from .entity import Entity
8# pylint: disable=missing-docstring,too-many-arguments
10class Alias(Entity):
11 def __init__(
12 self,
13 client: Elasticsearch,
14 name: str = None,
15 autobuild: t.Optional[bool] = True,
16 ):
17 super().__init__(client=client, name=name, autobuild=autobuild)
18 self.logger = getlogger('es_testbed.Alias')
20 def rollover(self) -> None:
21 es_api.rollover(self.client, self.name)
23 def verify(self, index_list: t.Sequence[str]) -> bool:
24 retval = False
25 res = es_api.resolver(self.client, self.name)
26 for idx, alias in enumerate(res['aliases']): 26 ↛ 35line 26 didn't jump to line 35, because the loop on line 26 didn't complete
27 if alias['name'] == self.name: 27 ↛ 30line 27 didn't jump to line 30, because the condition on line 27 was never false
28 self.logger.debug('Confirm match of alias %s at index %s', alias, idx)
29 else:
30 continue
31 if alias['indices'] == index_list: 31 ↛ 26line 31 didn't jump to line 26, because the condition on line 31 was never false
32 self.logger.debug('Confirm match of indices backed by alias %s', self.name)
33 retval = True
34 break
35 return retval