tests: Update tests, and fix some bugs.
This commit is contained in:
@@ -96,7 +96,7 @@ class FanModeManual(MinerConfigValue):
|
||||
return cls(**cls_conf)
|
||||
|
||||
def as_am_modern(self) -> dict:
|
||||
return {"bitmain-fan-ctrl": True, "bitmain-fan-pwn": str(self.speed)}
|
||||
return {"bitmain-fan-ctrl": True, "bitmain-fan-pwm": str(self.speed)}
|
||||
|
||||
def as_bosminer(self) -> dict:
|
||||
return {
|
||||
@@ -120,7 +120,7 @@ class FanModeImmersion(MinerConfigValue):
|
||||
return cls()
|
||||
|
||||
def as_am_modern(self) -> dict:
|
||||
return {"bitmain-fan-ctrl": True, "bitmain-fan-pwn": "0"}
|
||||
return {"bitmain-fan-ctrl": True, "bitmain-fan-pwm": "0"}
|
||||
|
||||
def as_bosminer(self) -> dict:
|
||||
return {"temp_control": {"mode": "disabled"}}
|
||||
@@ -156,7 +156,10 @@ class FanModeConfig(MinerConfigOption):
|
||||
if web_conf.get("bitmain-fan-ctrl") is not None:
|
||||
fan_manual = web_conf["bitmain-fan-ctrl"]
|
||||
if fan_manual:
|
||||
return cls.manual(speed=web_conf["bitmain-fan-pwm"])
|
||||
speed = int(web_conf["bitmain-fan-pwm"])
|
||||
if speed == 0:
|
||||
return cls.immersion()
|
||||
return cls.manual(speed=speed)
|
||||
else:
|
||||
return cls.normal()
|
||||
else:
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from tests.api_tests import *
|
||||
from tests.rpc_tests import *
|
||||
from tests.config_tests import TestConfig
|
||||
from tests.miners_tests import MinersTest
|
||||
from tests.network_tests import NetworkTest
|
||||
|
||||
@@ -128,9 +128,9 @@ class TestConfig(unittest.TestCase):
|
||||
def test_am_modern_serialize(self):
|
||||
correct_config = {
|
||||
"bitmain-fan-ctrl": True,
|
||||
"bitmain-fan-pwn": "90",
|
||||
"bitmain-fan-pwm": "90",
|
||||
"freq-level": "100",
|
||||
"miner-mode": "0",
|
||||
"miner-mode": 0,
|
||||
"pools": [
|
||||
{
|
||||
"url": "stratum+tcp://stratum.test.io:3333",
|
||||
|
||||
35
tests/config_tests/fans.py
Normal file
35
tests/config_tests/fans.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import unittest
|
||||
|
||||
from pyasic.config import FanModeConfig
|
||||
|
||||
|
||||
class TestFanConfig(unittest.TestCase):
|
||||
def test_serialize_and_deserialize(self):
|
||||
for fan_mode in FanModeConfig:
|
||||
with self.subTest(
|
||||
msg=f"Test serialization and deserialization of fan config",
|
||||
fan_mode=fan_mode,
|
||||
):
|
||||
conf = fan_mode()
|
||||
dict_conf = conf.as_dict()
|
||||
self.assertEqual(conf, FanModeConfig.from_dict(dict_conf))
|
||||
|
||||
def test_bosminer_deserialize_and_serialize(self):
|
||||
for fan_mode in FanModeConfig:
|
||||
with self.subTest(
|
||||
msg=f"Test serialization and deserialization of bosminer fan config",
|
||||
fan_mode=fan_mode,
|
||||
):
|
||||
conf = fan_mode()
|
||||
bos_conf = conf.as_bosminer()
|
||||
self.assertEqual(conf, FanModeConfig.from_bosminer(bos_conf))
|
||||
|
||||
def test_am_modern_deserialize_and_serialize(self):
|
||||
for fan_mode in FanModeConfig:
|
||||
with self.subTest(
|
||||
msg=f"Test serialization and deserialization of antminer modern fan config",
|
||||
fan_mode=fan_mode,
|
||||
):
|
||||
conf = fan_mode()
|
||||
am_conf = conf.as_am_modern()
|
||||
self.assertEqual(conf, FanModeConfig.from_am_modern(am_conf))
|
||||
Reference in New Issue
Block a user