forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_jolokia_include.py
51 lines (40 loc) · 1.39 KB
/
test_jolokia_include.py
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
#!/usr/bin/env python3
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
from collections.abc import MutableSequence
import pytest
from cmk.base.check_legacy_includes.jolokia import jolokia_basic_split
pytestmark = pytest.mark.checks
@pytest.mark.parametrize(
"line,length,result",
[
(list("ABCDEF"), 3, ["A", "B C D E", "F"]),
(list("ABCDEF"), 4, ["A", "B C D", "E", "F"]),
(list("AB"), 2, list("AB")),
],
)
def test_jolokia_basic_split(
line: MutableSequence[str], length: int, result: MutableSequence[str]
) -> None:
split_up = jolokia_basic_split(line, length)
assert result == split_up
@pytest.mark.parametrize(
"line,length",
[
(["too", "short"], 3),
(["too", "short", "aswell"], 4),
],
)
def test_jolokia_basic_split_fail_value(line: MutableSequence[str], length: int) -> None:
with pytest.raises(ValueError):
jolokia_basic_split(line, length)
@pytest.mark.parametrize(
"line,length",
[
(["too", "short"], 1),
],
)
def test_jolokia_basic_split_fail_notimplemented(line: MutableSequence[str], length: int) -> None:
with pytest.raises(NotImplementedError):
jolokia_basic_split(line, length)