-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtest_enums_collectoroperators.py
43 lines (37 loc) · 1.37 KB
/
test_enums_collectoroperators.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
import pytest
from yamlpath.enums import CollectorOperators
class Test_enums_CollectorOperators():
"""Tests for the CollectorOperators enumeration."""
def test_get_names(self):
assert CollectorOperators.get_names() == [
"ADDITION",
"NONE",
"SUBTRACTION",
"INTERSECTION",
]
@pytest.mark.parametrize("input,output", [
(CollectorOperators.ADDITION, "+"),
(CollectorOperators.NONE, ""),
(CollectorOperators.SUBTRACTION, "-"),
(CollectorOperators.INTERSECTION, "&"),
])
def test_str(self, input, output):
assert output == str(input)
@pytest.mark.parametrize("input,output", [
("+", CollectorOperators.ADDITION),
("-", CollectorOperators.SUBTRACTION),
("&", CollectorOperators.INTERSECTION),
("ADDITION", CollectorOperators.ADDITION),
("NONE", CollectorOperators.NONE),
("SUBTRACTION", CollectorOperators.SUBTRACTION),
("INTERSECTION", CollectorOperators.INTERSECTION),
(CollectorOperators.ADDITION, CollectorOperators.ADDITION),
(CollectorOperators.SUBTRACTION, CollectorOperators.SUBTRACTION),
(CollectorOperators.INTERSECTION, CollectorOperators.INTERSECTION),
(CollectorOperators.NONE, CollectorOperators.NONE),
])
def test_from_operator(self, input, output):
assert output == CollectorOperators.from_operator(input)
def test_from_operator_nameerror(self):
with pytest.raises(NameError):
CollectorOperators.from_operator("NO SUCH NAME")