tests: add more tests for miners.

This commit is contained in:
UpstreamData
2023-12-18 14:11:16 -07:00
parent 659dc55f3c
commit 0e492f1cfd
2 changed files with 37 additions and 1 deletions

View File

@@ -96,7 +96,10 @@ class TestAPIBase(unittest.IsolatedAsyncioTestCase):
commands = self.api.commands
for command in commands:
with self.subTest(msg=f"{self.api_str} {command}"):
with self.subTest(
msg=f"Test of command success on {self.api_str} API with command={command}",
command=command,
):
api_func = getattr(self.api, command)
mock_send_bytes.return_value = self.get_success_value(command)
try:

View File

@@ -39,6 +39,39 @@ class MinersTest(unittest.TestCase):
isinstance(miner, MINER_CLASSES[miner_model][miner_api])
)
def test_miner_data_map_keys(self):
keys = [
"api_ver",
"env_temp",
"errors",
"fan_psu",
"fans",
"fault_light",
"fw_ver",
"hashboards",
"hashrate",
"hostname",
"is_mining",
"mac",
"model",
"nominal_hashrate",
"pools",
"uptime",
"wattage",
"wattage_limit",
]
warnings.filterwarnings("ignore")
for miner_model in MINER_CLASSES.keys():
for miner_api in MINER_CLASSES[miner_model].keys():
with self.subTest(
msg=f"Data map key check of miner using model={miner_model}, api={miner_api}",
miner_model=miner_model,
miner_api=miner_api,
):
miner = MINER_CLASSES[miner_model][miner_api]("127.0.0.1")
miner_keys = sorted(list(miner.data_locations.keys()))
self.assertEqual(miner_keys, keys)
if __name__ == "__main__":
unittest.main()