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