summaryrefslogtreecommitdiff
path: root/testenv/tests
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-10-15 05:29:01 +0300
committerDevaev Maxim <[email protected]>2019-10-15 05:29:15 +0300
commite58ad66da98917d66f58731d041d4ddbe18befed (patch)
treecf9d0c9a92eac227427b352d607558733db13fa9 /testenv/tests
parenta88ad42501e3afd49bb02f186e787b6e14474640 (diff)
some validation
Diffstat (limited to 'testenv/tests')
-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))