Skip to content

Commit 5dd7908

Browse files
committed
Rewrite tests to be more realistic.
This patch improves tests to include the newly supported megaraid devices. To achieve this we rewrite the tests and use iterable side effects. As the modifications are significants this is the first commit with new structure but we will extend them in the future. Signed-off-by: Guillaume <[email protected]>
1 parent 19811e6 commit 5dd7908

7 files changed

+1799
-79
lines changed

tests/smartctl_outputs/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
from smartctl_outputs.smartctl_sda import INFO_SDA
3+
from smartctl_outputs.smartctl_nvme1 import INFO_NVME1
4+
from smartctl_outputs.smartctl_megaraid0 import INFO_MEGARAID0
5+
from smartctl_outputs.smartctl_megaraid1 import INFO_MEGARAID1
6+
7+
# Parse the INFO JSON string for each devices
8+
info_sda_dict = json.loads(INFO_SDA)
9+
info_nvme1_dict = json.loads(INFO_NVME1)
10+
info_megaraid0_dict = json.loads(INFO_MEGARAID0)
11+
info_megaraid1_dict = json.loads(INFO_MEGARAID1)
12+
13+
expected_info_dict = {
14+
"/dev/sda:sat": info_sda_dict,
15+
"/dev/nvme1:nvme": info_nvme1_dict,
16+
"/dev/bus/0:megaraid,0": info_megaraid0_dict,
17+
"/dev/bus/0:megaraid,1": info_megaraid1_dict,
18+
}
19+
20+
# Convert the result back to a JSON string
21+
EXPECTED_INFO = json.dumps(expected_info_dict, indent=2)
22+
23+
expected_health_dict = {
24+
"/dev/sda:sat": "PASSED",
25+
"/dev/nvme1:nvme": "PASSED",
26+
"/dev/bus/0:megaraid,0": "PASSED",
27+
"/dev/bus/0:megaraid,1": "PASSED",
28+
}
29+
30+
EXPECTED_HEALTH = json.dumps(expected_health_dict, indent=2)

0 commit comments

Comments
 (0)