Coverage for /Users/buh/.pyenv/versions/3.12.2/envs/es-testbed/lib/python3.12/site-packages/es_testbed/presets/searchable_test/definitions.py: 100%
29 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-08-21 12:05 -0600
« prev ^ index » next coverage.py v7.4.4, created at 2024-08-21 12:05 -0600
1"""Searchable Snapshot Test Built-in Plan"""
3import logging
4from pathlib import Path
5from json import loads
6from es_client.helpers.utils import get_yaml
7from . import scenarios
9logger = logging.getLogger(__name__)
12def baseplan() -> dict:
13 """Return the base plan object from plan.yml"""
14 return get_yaml((modpath() / 'plan.yml'))
17def buildlist() -> list:
18 """Return the list of index build schemas from buildlist.yml"""
19 return get_yaml((modpath() / 'buildlist.yml'))
22def get_plan(scenario: str = None) -> dict:
23 """Return the plan dict based on scenario"""
24 retval = baseplan()
25 retval.update(buildlist())
26 if not scenario:
27 return retval
28 newvals = getattr(scenarios, scenario)
29 ilm = {}
30 if 'ilm' in newvals:
31 ilm = newvals.pop('ilm')
32 if ilm:
33 retval['ilm'].update(ilm)
34 retval.update(newvals)
35 return retval
38def mappings() -> dict:
39 """Return the index mappings from mappings.json"""
40 return loads((modpath() / 'mappings.json').read_text(encoding='UTF-8'))
43def modpath() -> Path:
44 """Return the local file path"""
45 return Path(__file__).parent.resolve()
48def settings() -> dict:
49 """Return the index settings from settings.json"""
50 return loads((modpath() / 'settings.json').read_text(encoding='UTF-8'))