-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_data.py
49 lines (40 loc) · 1.54 KB
/
test_data.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
from moonwatcher.utils.data import OPERATOR_DICT, Task, DataType
def test_operator_dict():
test_cases = [
("<", 3, 5, True),
("<", 5, 3, False),
(">", 5, 3, True),
(">", 3, 5, False),
(">=", 5, 5, True),
(">=", 4, 5, False),
("<=", 3, 3, True),
("<=", 5, 3, False),
("==", 5, 5, True),
("==", 5, 4, False),
("=", 5, 5, True),
("=", 5, 4, False),
("!=", 5, 4, True),
("!=", 5, 5, False),
]
for operator, left, right, expected in test_cases:
assert (
OPERATOR_DICT[operator](left, right) == expected
), f"Failed for operator {operator} with values {left} and {right}"
def test_task_enum():
assert Task.CLASSIFICATION.value == "classification"
assert Task.DETECTION.value == "detection"
def test_data_type_enum():
assert DataType.DATASET.value == "dataset"
assert DataType.SLICE.value == "slice"
assert DataType.MODEL.value == "model"
assert DataType.CHECK.value == "check"
assert DataType.CHECKSUITE.value == "checksuite"
assert DataType.CHECK_REPORT.value == "check_report"
assert DataType.CHECKSUITE_REPORT.value == "checksuite_report"
assert DataType.PREDICTIONS.value == "predictions"
assert DataType.GROUNDTRUTHS.value == "groundtruths"
def test_all_operators_present():
expected_operators = {"<", ">", ">=", "<=", "==", "=", "!="}
assert (
set(OPERATOR_DICT.keys()) == expected_operators
), "Not all expected operators are present in the dictionary"