From 08cbd8826238d1e65c98a762bb3002ec93d184c4 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:13:30 +0900 Subject: [PATCH] chore: add ip entry validator tests --- tests/test_ip.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_ip.py b/tests/test_ip.py index aae56ef..5b5f9e1 100644 --- a/tests/test_ip.py +++ b/tests/test_ip.py @@ -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