mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 17:57:06 +02:00
chore: add ip entry validator tests
This commit is contained in:
parent
5b5e91c2fa
commit
08cbd88262
@ -1,6 +1,25 @@
|
||||
import pytest
|
||||
|
||||
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:
|
||||
ip = "192.168.1.1:100"
|
||||
@ -15,6 +34,7 @@ def test_invalid_port() -> None:
|
||||
with pytest.raises(Exception):
|
||||
validate_ip(ip)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("port", [-1, 65536])
|
||||
def test_port_out_of_range(port: int) -> None:
|
||||
ip = f"192.168.1.1:{port}"
|
||||
@ -27,6 +47,7 @@ def test_invalid_socket() -> None:
|
||||
with pytest.raises(Exception):
|
||||
validate_ip(ip)
|
||||
|
||||
|
||||
# TODO: ?
|
||||
def test_ipdb() -> None:
|
||||
pass
|
||||
|
||||
Loading…
Reference in New Issue
Block a user