mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
chore: add ip entry validator tests
This commit is contained in:
1 parent
5b5e91c2fa
commit
08cbd88262
1 file changed
+21
@@ -1,6 +1,25 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dzgui.api.servers import validate_ip
|
from dzgui.api.servers import validate_ip
|
||||||
|
from dzgui.views.components.entry import validate_ip_truthy
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.FOO
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"ip",
|
||||||
|
[
|
||||||
|
("foo", False),
|
||||||
|
("999", False),
|
||||||
|
("192.168.1.101", False),
|
||||||
|
("192.168.1.101:", False),
|
||||||
|
(":1", False),
|
||||||
|
("192.168.1.101:27016", True),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_ip_entry(ip) -> None:
|
||||||
|
string, state = ip
|
||||||
|
assert validate_ip_truthy(string) is state
|
||||||
|
|
||||||
|
|
||||||
def test_ip_validation() -> None:
|
def test_ip_validation() -> None:
|
||||||
ip = "192.168.1.1:100"
|
ip = "192.168.1.1:100"
|
||||||
@@ -15,6 +34,7 @@ def test_invalid_port() -> None:
|
|||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
validate_ip(ip)
|
validate_ip(ip)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("port", [-1, 65536])
|
@pytest.mark.parametrize("port", [-1, 65536])
|
||||||
def test_port_out_of_range(port: int) -> None:
|
def test_port_out_of_range(port: int) -> None:
|
||||||
ip = f"192.168.1.1:{port}"
|
ip = f"192.168.1.1:{port}"
|
||||||
@@ -27,6 +47,7 @@ def test_invalid_socket() -> None:
|
|||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
validate_ip(ip)
|
validate_ip(ip)
|
||||||
|
|
||||||
|
|
||||||
# TODO: ?
|
# TODO: ?
|
||||||
def test_ipdb() -> None:
|
def test_ipdb() -> None:
|
||||||
pass
|
pass
|
||||||
Reference in new issue
Block a user