Skip to content

Commit

Permalink
Rewrite tests to be more realistic.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gthvn1 committed Jan 28, 2025
1 parent 19811e6 commit 5dd7908
Show file tree
Hide file tree
Showing 7 changed files with 1,799 additions and 79 deletions.
Empty file.
30 changes: 30 additions & 0 deletions tests/smartctl_outputs/smartctl_expected_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import json
from smartctl_outputs.smartctl_sda import INFO_SDA
from smartctl_outputs.smartctl_nvme1 import INFO_NVME1
from smartctl_outputs.smartctl_megaraid0 import INFO_MEGARAID0
from smartctl_outputs.smartctl_megaraid1 import INFO_MEGARAID1

# Parse the INFO JSON string for each devices
info_sda_dict = json.loads(INFO_SDA)
info_nvme1_dict = json.loads(INFO_NVME1)
info_megaraid0_dict = json.loads(INFO_MEGARAID0)
info_megaraid1_dict = json.loads(INFO_MEGARAID1)

expected_info_dict = {
"/dev/sda:sat": info_sda_dict,
"/dev/nvme1:nvme": info_nvme1_dict,
"/dev/bus/0:megaraid,0": info_megaraid0_dict,
"/dev/bus/0:megaraid,1": info_megaraid1_dict,
}

# Convert the result back to a JSON string
EXPECTED_INFO = json.dumps(expected_info_dict, indent=2)

expected_health_dict = {
"/dev/sda:sat": "PASSED",
"/dev/nvme1:nvme": "PASSED",
"/dev/bus/0:megaraid,0": "PASSED",
"/dev/bus/0:megaraid,1": "PASSED",
}

EXPECTED_HEALTH = json.dumps(expected_health_dict, indent=2)
Loading

0 comments on commit 5dd7908

Please sign in to comment.