summaryrefslogtreecommitdiff
path: root/testenv
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-10-02 10:22:43 +0300
committerDevaev Maxim <[email protected]>2020-10-09 03:51:19 +0300
commit5bfde6ceae5af9c47c7a86a6ee1d9fb180b39b54 (patch)
tree7d02fbc1b2170c009c4be099d1e5a75f35bc32e9 /testenv
parent3c4d38f7551c9bd69ac4646d7704fc271e32bdc3 (diff)
otgnet stubs
Diffstat (limited to 'testenv')
-rw-r--r--testenv/tests/validators/test_net.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/testenv/tests/validators/test_net.py b/testenv/tests/validators/test_net.py
index 486154fc..d3d4703b 100644
--- a/testenv/tests/validators/test_net.py
+++ b/testenv/tests/validators/test_net.py
@@ -20,6 +20,7 @@
# ========================================================================== #
+from typing import List
from typing import Any
import pytest
@@ -27,8 +28,10 @@ import pytest
from kvmd.validators import ValidatorError
from kvmd.validators.net import valid_ip_or_host
from kvmd.validators.net import valid_ip
+from kvmd.validators.net import valid_net
from kvmd.validators.net import valid_rfc_host
from kvmd.validators.net import valid_port
+from kvmd.validators.net import valid_ports_list
from kvmd.validators.net import valid_mac
from kvmd.validators.net import valid_ssl_ciphers
@@ -88,6 +91,37 @@ def test_fail__valid_ip(arg: Any) -> None:
# =====
@pytest.mark.parametrize("arg", [
+ "127.0.0.0/24 ",
+ "8.8.8.8/31",
+ "::/16",
+ "::ffff:0:0:0/96",
+ "64:ff9b::/96",
+])
+def test_ok__valid_net(arg: Any) -> None:
+ assert valid_net(arg) == arg.strip()
+
+
+ "127.0.0.1/33",
+ "127.0.0.1/0",
+ "127.0.0.1/",
+ "127.0.0.1",
+ "8.8.8.8//31",
+ "ya.ru",
+ "1",
+ "1.1.1",
+ "1.1.1.",
+ ":",
+ "",
+ None,
+])
+def test_fail__valid_net(arg: Any) -> None:
+ with pytest.raises(ValidatorError):
+ print(valid_net(arg))
+
+
+# =====
"yandex.ru ",
"foobar",
"foo-bar.ru",
@@ -125,6 +159,26 @@ def test_fail__valid_port(arg: Any) -> None:
# =====
[email protected]("arg, retval", [
+ ("", []),
+ (",, , ", []),
+ ("0 ", [0]),
+ ("1,", [1]),
+ ("22,23", [22, 23]),
+ ("80,443,443,", [80, 443, 443]),
+ (65535, [65535]),
+])
+def test_ok__valid_ports_list(arg: Any, retval: List[int]) -> None:
+ assert valid_ports_list(arg) == retval
+
+
[email protected]("arg", ["test", "13,test", None, 1.1])
+def test_fail__valid_ports_list(arg: Any) -> None:
+ with pytest.raises(ValidatorError):
+ print(valid_ports_list(arg))
+
+
+# =====
@pytest.mark.parametrize("arg", [
" 00:00:00:00:00:00 ",
" 9f:00:00:00:00:00 ",