mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
otgnet stubs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -86,6 +89,37 @@ def test_fail__valid_ip(arg: Any) -> None:
|
||||
print(valid_ip(arg))
|
||||
|
||||
|
||||
# =====
|
||||
@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()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("arg", [
|
||||
"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))
|
||||
|
||||
|
||||
# =====
|
||||
@pytest.mark.parametrize("arg", [
|
||||
"yandex.ru ",
|
||||
@@ -124,6 +158,26 @@ def test_fail__valid_port(arg: Any) -> None:
|
||||
print(valid_port(arg))
|
||||
|
||||
|
||||
# =====
|
||||
@pytest.mark.parametrize("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
|
||||
|
||||
|
||||
@pytest.mark.parametrize("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 ",
|
||||
|
||||
Reference in New Issue
Block a user