Coverage for tests/integration/test_frozen_indices.py: 95%

38 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-25 19:21 -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 PlanBuilder, TestBed 

5from es_testbed.defaults import NAMEMAPPER 

6from es_testbed.helpers.es_api import get_write_index 

7 

8@pytest.fixture(scope='module') 

9def settings(prefix, uniq, repo): 

10 if not repo: 10 ↛ 11line 10 didn't jump to line 11, because the condition on line 10 was never true

11 pytest.skip('No snapshot repository', allow_module_level=True) 

12 return { 

13 'type': 'indices', 

14 'prefix': prefix, 

15 'rollover_alias': True, 

16 'uniq': uniq, 

17 'repository': repo, 

18 'defaults': { 

19 'entity_count': 3, 

20 'docs': 10, 

21 'match': True, 

22 'searchable': 'frozen', 

23 } 

24 } 

25 

26class TestFrozenRolloverNoILMIndices: 

27 @pytest.fixture(scope="class") 

28 def tb(self, client, settings): 

29 theplan = PlanBuilder(settings=settings).plan 

30 teebee = TestBed(client, plan=theplan) 

31 teebee.setup() 

32 yield teebee 

33 teebee.teardown() 

34 

35 def test_entity_count(self, tb): 

36 assert len(tb.tracker.entities.entity_list) == 3 

37 

38 def test_first_index(self, tb, frozen, prefix, uniq): 

39 value = f'{frozen}{prefix}-{NAMEMAPPER['index']}-{uniq}-000001' 

40 assert tb.tracker.entities.entity_list[0].name == value 

41 

42 def test_last_index(self, tb, prefix, uniq): 

43 value = f'{prefix}-{NAMEMAPPER['index']}-{uniq}-000003' 

44 assert tb.tracker.entities.last.name == value 

45 

46 def test_write_index(self, tb, prefix, uniq): 

47 alias = f'{prefix}-{NAMEMAPPER['index']}-{uniq}' 

48 assert tb.tracker.entities.last.name == get_write_index(tb.client, alias) 

49 

50 def test_index_template(self, tb, prefix, uniq): 

51 components = [] 

52 components.append(f'{prefix}-{NAMEMAPPER['component']}-{uniq}-000001') 

53 components.append(f'{prefix}-{NAMEMAPPER['component']}-{uniq}-000002') 

54 assert tb.tracker.components.entity_list == components 

55 template = f'{prefix}-{NAMEMAPPER['template']}-{uniq}-000001' 

56 assert tb.tracker.templates.last == template 

57 result = tb.client.indices.get_index_template(name=template)['index_templates'] 

58 assert len(result) == 1 

59 assert result[0]['index_template']['composed_of'] == components