This commit is contained in:
Devaev Maxim 2020-09-09 03:58:43 +03:00
parent 9c78f4f631
commit 2211124ecb
2 changed files with 17 additions and 0 deletions

View File

@ -82,6 +82,7 @@ def test_fail__valid_gpio_pin_optional(arg: Any) -> None:
"_",
"_foo_bar_",
" aix",
"a" * 255,
])
def test_ok__valid_otg_gadget(arg: Any) -> None:
assert valid_otg_gadget(arg) == arg.strip()
@ -93,6 +94,7 @@ def test_ok__valid_otg_gadget(arg: Any) -> None:
"te~st",
"-",
"-foo_bar",
"a" * 256,
" ",
"",
None,

View File

@ -29,6 +29,7 @@ from kvmd.keyboard.mappings import KEYMAP
from kvmd.validators import ValidatorError
from kvmd.validators.kvm import valid_atx_power_action
from kvmd.validators.kvm import valid_atx_button
from kvmd.validators.kvm import valid_info_fields
from kvmd.validators.kvm import valid_log_seek
from kvmd.validators.kvm import valid_stream_quality
from kvmd.validators.kvm import valid_stream_fps
@ -63,6 +64,20 @@ def test_fail__valid_atx_button(arg: Any) -> None:
print(valid_atx_button(arg))
# =====
@pytest.mark.parametrize("arg", [" foo ", "bar", "foo, ,bar,", " ", " , ", ""])
def test_ok__valid_info_fields(arg: Any) -> None:
value = valid_info_fields(arg, set(["foo", "bar"]))
assert type(value) == set # pylint: disable=unidiomatic-typecheck
assert value == set(filter(None, map(str.strip, str(arg).split(","))))
@pytest.mark.parametrize("arg", ["xxx", "yyy", "foo,xxx", None])
def test_fail__valid_info_fields(arg: Any) -> None:
with pytest.raises(ValidatorError):
print(valid_info_fields(arg, set(["foo", "bar"])))
# =====
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13])
def test_ok__valid_log_seek(arg: Any) -> None: