optional quality and resolution

This commit is contained in:
Devaev Maxim
2020-07-13 04:10:26 +03:00
parent 07fb731b21
commit 77f3dab55c
8 changed files with 122 additions and 29 deletions

View File

@@ -142,6 +142,7 @@ def test_fail__valid_float_f01(arg: Any) -> None:
# =====
@pytest.mark.parametrize("arg, retval", [
("a, b, c", ["a", "b", "c"]),
("a, b,, c", ["a", "b", "c"]),
("a b c", ["a", "b", "c"]),
(["a", "b", "c"], ["a", "b", "c"]),
("", []),

View File

@@ -32,6 +32,7 @@ from kvmd.validators.kvm import valid_atx_button
from kvmd.validators.kvm import valid_log_seek
from kvmd.validators.kvm import valid_stream_quality
from kvmd.validators.kvm import valid_stream_fps
from kvmd.validators.kvm import valid_stream_resolution
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
@@ -104,6 +105,20 @@ def test_fail__valid_stream_fps(arg: Any) -> None:
print(valid_stream_fps(arg))
# =====
@pytest.mark.parametrize("arg", ["1280x720 ", "1x1"])
def test_ok__valid_stream_resolution(arg: Any) -> None:
value = valid_stream_resolution(arg)
assert type(value) == str # pylint: disable=unidiomatic-typecheck
assert value == str(arg).strip()
@pytest.mark.parametrize("arg", ["x", None, "0x0", "0x1", "1x0", "1280", "1280x", "1280x720x"])
def test_fail__valid_stream_resolution(arg: Any) -> None:
with pytest.raises(ValidatorError):
print(valid_stream_resolution(arg))
# =====
def test_ok__valid_hid_key() -> None:
for key in KEYMAP: