Coverage for tests/integration/test_basic_indices.py: 100%
35 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 18:35 -0600
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 18:35 -0600
1"""Test functions in es_testbed.TestBed"""
2# pylint: disable=redefined-outer-name,missing-function-docstring,missing-class-docstring
3import pytest
4from es_testbed import TestPlan, TestBed
5from es_testbed.defaults import NAMEMAPPER
6from es_testbed.helpers.es_api import get_write_index
8@pytest.fixture(scope='module')
9def settings(prefix, uniq):
10 return {
11 'type': 'indices',
12 'prefix': prefix,
13 'rollover_alias': True,
14 'uniq': uniq,
15 'ilm': False
16 }
18class TestBasicIndices:
19 @pytest.fixture(scope="class")
20 def tb(self, client, settings):
21 teebee = TestBed(client, plan=TestPlan(settings=settings))
22 teebee.setup()
23 yield teebee
24 teebee.teardown()
26 def test_entity_count(self, tb):
27 assert len(tb.tracker.entities.entity_list) == 3
29 def test_first_index(self, tb, prefix, uniq):
30 value = f'{prefix}-{NAMEMAPPER['index']}-{uniq}-000001'
31 assert tb.tracker.entities.entity_list[0].name == value
33 def test_last_index(self, tb, prefix, uniq):
34 value = f'{prefix}-{NAMEMAPPER['index']}-{uniq}-000003'
35 assert tb.tracker.entities.last.name == value
37 def test_write_index(self, tb, prefix, uniq):
38 alias = f'{prefix}-{NAMEMAPPER['index']}-{uniq}'
39 assert tb.tracker.entities.last.name == get_write_index(tb.client, alias)
41 def test_index_template(self, tb, prefix, uniq):
42 components = []
43 components.append(f'{prefix}-{NAMEMAPPER['component']}-{uniq}-000001')
44 components.append(f'{prefix}-{NAMEMAPPER['component']}-{uniq}-000002')
45 assert tb.tracker.components.entity_list == components
46 template = f'{prefix}-{NAMEMAPPER['template']}-{uniq}-000001'
47 assert tb.tracker.templates.last == template
48 result = tb.client.indices.get_index_template(name=template)['index_templates']
49 assert len(result) == 1
50 assert result[0]['index_template']['composed_of'] == components