From 560241179af12cd300185aa8705ec3d38d36d9a6 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Sat, 4 Apr 2026 16:24:22 +0200 Subject: [PATCH] Add tests for jeb_utils.utils.test_is_valid_host --- tests/unit/utils/test_is_valid_host.py | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/unit/utils/test_is_valid_host.py diff --git a/tests/unit/utils/test_is_valid_host.py b/tests/unit/utils/test_is_valid_host.py new file mode 100644 index 0000000..9753806 --- /dev/null +++ b/tests/unit/utils/test_is_valid_host.py @@ -0,0 +1,43 @@ +from src.jeb_utils.utils import is_valid_host +import pytest + +@pytest.mark.parametrize('host,expected', [ + ('0.0.0.0', True), + ('0.0.0.1', True), + ('1.0.0.1', True), + ('1.1.1.1', True), + ('255.255.255.255', True), + ('42.54.32.78', True), + ('0.0.255.255', True), + ('255.255.0.0', True), + ('192.168.0.0', True), + ('192.168.23.1', True), + ('10.0.0.0', True), + ('10.0.0.1', True), + ('10.1.1.1', True), + ('10.54.65.129', True), + ('127.0.0.1', True), + ('127.0.0.42', True), + ('127.0.1.42', True), + + ('0.0.a0.0', False), + ('a0.0.0.0', False), + ('a0.0.,0.0', False), + ('a0.0.0,0', False), + ('a0.0.0,0.0', False), + ('256.255.255.255', False), + ('-1.0.0.0', False), + ('0.0.0', False), + ('0.0.1', False), + ('1.0.0', False), + ('1.0.1', False), + ('1.1.1', False), + ('0.0.0.0:0', False), + ('0.0.0.0:1', False), + ('0.0.0.0:65535', False), + ('0.0.0.0:65536', False), + ('', False), + ('', False), +]) +def test_is_valid_host(host, expected): + assert is_valid_host(host) == expected \ No newline at end of file