-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
43 lines (38 loc) · 1.03 KB
/
test_utils.py
File metadata and controls
43 lines (38 loc) · 1.03 KB
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
# Copyright Stacklet, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
from stacklet.client.platform.formatter import (
JSONFormatter,
RawFormatter,
YAMLFormatter,
)
from stacklet.client.platform.utils import get_log_level
class TestUtils:
@pytest.mark.parametrize(
"verbosity,level",
[
(-9999, 50),
(0, 40),
(1, 30),
(2, 20),
(3, 10),
(4, 0),
(5, 0),
(6, 0),
(9999, 0),
],
)
def test_get_log_level(self, verbosity, level):
assert get_log_level(verbosity) == level
@pytest.mark.parametrize(
"formatter,expected_output",
[
(RawFormatter, "{'foo': 'bar'}"),
(JSONFormatter, '{\n "foo": "bar"\n}'),
(YAMLFormatter, "foo: bar\n"),
],
)
def test_formatters(self, formatter, expected_output):
input_data = {"foo": "bar"}
result = formatter()(input_data)
assert result == expected_output