init
Build and Push Container / build-and-push (push) Successful in 19s

This commit is contained in:
2026-08-01 19:07:05 -04:00
commit e360546de9
17 changed files with 15731 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
"""Tests for ip_lookup module."""
from unittest.mock import MagicMock, patch
from ip_lookup import get_ipv4, get_ipv6
class TestGetIpv4:
def test_returns_stripped_ip(self) -> None:
mock_result = MagicMock()
mock_result.stdout = " 1.2.3.4 \n"
with patch("ip_lookup.subprocess.run", return_value=mock_result) as mock_run:
ip = get_ipv4()
assert ip == "1.2.3.4"
mock_run.assert_called_once_with(["curl", "-4", "ifconfig.me"], capture_output=True, text=True, check=False)
def test_empty_response(self) -> None:
mock_result = MagicMock()
mock_result.stdout = ""
with patch("ip_lookup.subprocess.run", return_value=mock_result):
ip = get_ipv4()
assert ip == ""
class TestGetIpv6:
def test_returns_stripped_ip(self) -> None:
mock_result = MagicMock()
mock_result.stdout = " 2001:db8::1 \n"
with patch("ip_lookup.subprocess.run", return_value=mock_result) as mock_run:
ip = get_ipv6()
assert ip == "2001:db8::1"
mock_run.assert_called_once_with(["curl", "-6", "ifconfig.me"], capture_output=True, text=True, check=False)
def test_empty_response(self) -> None:
mock_result = MagicMock()
mock_result.stdout = ""
with patch("ip_lookup.subprocess.run", return_value=mock_result):
ip = get_ipv6()
assert ip == ""