summaryrefslogtreecommitdiff
path: root/testenv
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2023-03-06 03:01:12 +0200
committerMaxim Devaev <[email protected]>2023-03-06 03:16:37 +0200
commit5495f70564e03ae0d6ac81866a37cdd79858d4e4 (patch)
tree5f72e11179000691bad65ff3d69647ae706e2237 /testenv
parentc63bb2adb788ed07d12f446ee12bd692004b59d6 (diff)
msd images tree
Diffstat (limited to 'testenv')
-rw-r--r--testenv/tests/validators/test_kvm.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/testenv/tests/validators/test_kvm.py b/testenv/tests/validators/test_kvm.py
index d9f88ad3..f9990194 100644
--- a/testenv/tests/validators/test_kvm.py
+++ b/testenv/tests/validators/test_kvm.py
@@ -27,6 +27,7 @@ import pytest
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_msd_image_name
from kvmd.validators.kvm import valid_info_fields
from kvmd.validators.kvm import valid_log_seek
from kvmd.validators.kvm import valid_stream_quality
@@ -61,6 +62,64 @@ def test_fail__valid_atx_button(arg: Any) -> None:
# =====
[email protected]("arg, retval", [
+ ("archlinux-2018.07.01-i686.iso", "archlinux-2018.07.01-i686.iso"),
+ ("archlinux-2018.07.01-x86_64.iso", "archlinux-2018.07.01-x86_64.iso"),
+ ("dsl-4.11.rc1.iso", "dsl-4.11.rc1.iso"),
+ ("systemrescuecd-x86-5.3.1.iso", "systemrescuecd-x86-5.3.1.iso"),
+ ("ubuntu-16.04.5-desktop-i386.iso", "ubuntu-16.04.5-desktop-i386.iso"),
+ (" тест(){}[ \t].iso\t", "тест(){}[ _].iso"),
+ ("\n" + "x" * 1000, "x" * 255),
+ ("test", "test"),
+ ("test test [test] #test$", "test test [test] #test$"),
+ (".test", ".test"),
+ ("..test", "..test"),
+ ("..тест..", "..тест.."),
+ ("..те\\ст..", "..те\\ст.."),
+ (".....", "....."),
+ (".....txt", ".....txt"),
+ (" .. .", ".. ."),
+ ("..\n.", ".._."),
+ ("test/", "test"),
+ ("/test", "test"),
+ ("foo/bar.iso", "foo/bar.iso"),
+ ("//foo//bar.iso", "foo/bar.iso"),
+ ("foo/lost-found/bar.iso", "foo/lost-found/bar.iso"),
+ ("/bar.iso/", "bar.iso"),
+
+])
+def test_ok__valid_msd_image_name(arg: Any, retval: str) -> None:
+ assert valid_msd_image_name(arg) == retval
+
+
+ ".",
+ "..",
+ " ..",
+ "../test",
+ "./.",
+ "../.",
+ "./..",
+ "../..",
+ "/ ..",
+ ".. /",
+ "/.. /",
+ "foo/../bar.iso",
+ "foo/./foo.iso",
+ "foo/lost+found/bar.iso",
+ "../bar.iso",
+ "/../bar.iso",
+ "foo/.__bar.iso",
+ "",
+ " ",
+ None,
+])
+def test_fail__valid_msd_image_name(arg: Any) -> None:
+ with pytest.raises(ValidatorError):
+ valid_msd_image_name(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"]))