File: create_index_test.py

package info (click to toggle)
elastalert 0.2.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,472 kB
  • sloc: python: 12,252; makefile: 108; sh: 2
file content (53 lines) | stat: -rw-r--r-- 1,548 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
import json

import pytest

import elastalert.create_index

es_mappings = [
    'elastalert',
    'elastalert_error',
    'elastalert_status',
    'past_elastalert',
    'silence'
]


@pytest.mark.parametrize('es_mapping', es_mappings)
def test_read_default_index_mapping(es_mapping):
    mapping = elastalert.create_index.read_es_index_mapping(es_mapping)
    assert es_mapping not in mapping
    print((json.dumps(mapping, indent=2)))


@pytest.mark.parametrize('es_mapping', es_mappings)
def test_read_es_5_index_mapping(es_mapping):
    mapping = elastalert.create_index.read_es_index_mapping(es_mapping, 5)
    assert es_mapping in mapping
    print((json.dumps(mapping, indent=2)))


@pytest.mark.parametrize('es_mapping', es_mappings)
def test_read_es_6_index_mapping(es_mapping):
    mapping = elastalert.create_index.read_es_index_mapping(es_mapping, 6)
    assert es_mapping not in mapping
    print((json.dumps(mapping, indent=2)))


def test_read_default_index_mappings():
    mappings = elastalert.create_index.read_es_index_mappings()
    assert len(mappings) == len(es_mappings)
    print((json.dumps(mappings, indent=2)))


def test_read_es_5_index_mappings():
    mappings = elastalert.create_index.read_es_index_mappings(5)
    assert len(mappings) == len(es_mappings)
    print((json.dumps(mappings, indent=2)))


def test_read_es_6_index_mappings():
    mappings = elastalert.create_index.read_es_index_mappings(6)
    assert len(mappings) == len(es_mappings)
    print((json.dumps(mappings, indent=2)))