diff options
author | Devaev Maxim <[email protected]> | 2020-09-09 05:23:37 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-09-09 05:23:37 +0300 |
commit | a9a6f477bc213b8e7ee87db8c912e618f6157d9d (patch) | |
tree | ccc0c23c2c7352095a9bfe53f4ef110232d62e3d /testenv | |
parent | 2211124ecba827c916882f3a291d8b227ea5fdcf (diff) |
tests
Diffstat (limited to 'testenv')
-rw-r--r-- | testenv/tests/validators/test_kvm.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testenv/tests/validators/test_kvm.py b/testenv/tests/validators/test_kvm.py index 61f5a7be..cab03198 100644 --- a/testenv/tests/validators/test_kvm.py +++ b/testenv/tests/validators/test_kvm.py @@ -20,6 +20,7 @@ # ========================================================================== # +from typing import Callable from typing import Any import pytest @@ -38,6 +39,9 @@ from kvmd.validators.kvm import valid_hid_key from kvmd.validators.kvm import valid_hid_mouse_move from kvmd.validators.kvm import valid_hid_mouse_button from kvmd.validators.kvm import valid_hid_mouse_wheel +from kvmd.validators.kvm import valid_ugpio_driver +from kvmd.validators.kvm import valid_ugpio_channel +from kvmd.validators.kvm import valid_ugpio_mode # ===== @@ -197,3 +201,47 @@ def test_ok__valid_hid_mouse_wheel__p200() -> None: def test_fail__valid_hid_mouse_wheel(arg: Any) -> None: with pytest.raises(ValidatorError): print(valid_hid_mouse_wheel(arg)) + + +# ===== [email protected]("validator", [valid_ugpio_driver, valid_ugpio_channel]) [email protected]("arg", [ + "test-", + "glados", + "test", + "_", + "_foo_bar_", + " aix", + "a" * 255, +]) +def test_ok__valid_ugpio_item(validator: Callable[[Any], str], arg: Any) -> None: + assert validator(arg) == arg.strip() + + [email protected]("validator", [valid_ugpio_driver, valid_ugpio_channel]) [email protected]("arg", [ + "ัะตัั", + "-molestia", + "te~st", + "-", + "-foo_bar", + "a" * 256, + " ", + "", + None, +]) +def test_fail__valid_ugpio_item(validator: Callable[[Any], str], arg: Any) -> None: + with pytest.raises(ValidatorError): + print(validator(arg)) + + +# ===== [email protected]("arg", ["Input ", " OUTPUT "]) +def test_ok__valid_ugpio_mode(arg: Any) -> None: + assert valid_ugpio_mode(arg) == arg.strip().lower() + + [email protected]("arg", ["test", "", None]) +def test_fail__valid_ugpio_mode(arg: Any) -> None: + with pytest.raises(ValidatorError): + print(valid_ugpio_mode(arg)) |