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

33 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 

5 

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

7def settings(prefix, uniq, repo): 

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

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

10 return { 

11 'type': 'indices', 

12 'prefix': prefix, 

13 'rollover_alias': False, 

14 'repository': repo, 

15 'uniq': uniq, 

16 'defaults': { 

17 'entity_count': 3, 

18 'docs': 10, 

19 'match': True, 

20 'searchable': 'frozen', 

21 } 

22 } 

23 

24class TestManualFrozenIndices: 

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

26 def tb(self, client, settings): 

27 theplan = PlanBuilder(settings=settings).plan 

28 teebee = TestBed(client, plan=theplan) 

29 teebee.setup() 

30 yield teebee 

31 teebee.teardown() 

32 

33 def test_entity_count(self, tb): 

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

35 

36 def test_first_index(self, tb, frozen, namecore): 

37 value = f'{frozen}{namecore('index')}-000001' 

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

39 

40 def test_last_index(self, tb, frozen, namecore): 

41 value = f'{frozen}{namecore('index')}-000003' 

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

43 

44 def test_index_template(self, tb, namecore): 

45 components = [] 

46 components.append(f'{namecore('component')}-000001') 

47 components.append(f'{namecore('component')}-000002') 

48 assert tb.tracker.components.entity_list == components 

49 template = f'{namecore('template')}-000001' 

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

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

52 assert len(result) == 1 

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