summaryrefslogtreecommitdiff
path: root/testenv/tests/validators/test_hw.py
diff options
context:
space:
mode:
Diffstat (limited to 'testenv/tests/validators/test_hw.py')
-rw-r--r--testenv/tests/validators/test_hw.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/testenv/tests/validators/test_hw.py b/testenv/tests/validators/test_hw.py
index 2c93d3eb..a10a5feb 100644
--- a/testenv/tests/validators/test_hw.py
+++ b/testenv/tests/validators/test_hw.py
@@ -28,6 +28,8 @@ from kvmd.validators import ValidatorError
from kvmd.validators.hw import valid_tty_speed
from kvmd.validators.hw import valid_gpio_pin
from kvmd.validators.hw import valid_gpio_pin_optional
+from kvmd.validators.hw import valid_otg_gadget
+from kvmd.validators.hw import valid_otg_id
# =====
@@ -70,3 +72,45 @@ def test_ok__valid_gpio_pin_optional(arg: Any) -> None:
def test_fail__valid_gpio_pin_optional(arg: Any) -> None:
with pytest.raises(ValidatorError):
print(valid_gpio_pin_optional(arg))
+
+
+# =====
+ "test-",
+ "glados",
+ "test",
+ "_",
+ "_foo_bar_",
+ " aix",
+])
+def test_ok__valid_otg_gadget(arg: Any) -> None:
+ assert valid_otg_gadget(arg) == arg.strip()
+
+
+ "ั‚ะตัั‚",
+ "-molestia",
+ "te~st",
+ "-",
+ "-foo_bar",
+ " ",
+ "",
+ None,
+])
+def test_fail__valid_otg_gadget(arg: Any) -> None:
+ with pytest.raises(ValidatorError):
+ print(valid_otg_gadget(arg))
+
+
+# =====
[email protected]("arg", ["0 ", 0, 1, 13, 65535])
+def test_ok__valid_otg_id(arg: Any) -> None:
+ value = valid_otg_id(arg)
+ assert type(value) == int # pylint: disable=unidiomatic-typecheck
+ assert value == int(str(arg).strip())
+
+
[email protected]("arg", ["test", "", None, -1, -13, 1.1, 65534.5, 65536])
+def test_fail__valid_otg_id(arg: Any) -> None:
+ with pytest.raises(ValidatorError):
+ print(valid_otg_id(arg))