23 lines
721 B
Python
23 lines
721 B
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from scripts.env_check import _local_ips
|
|
|
|
|
|
class EnvCheckTests(unittest.TestCase):
|
|
def test_local_ips_skips_all_loopback_aliases(self) -> None:
|
|
fake_info = [
|
|
(None, None, None, None, ("127.0.0.1", 0)),
|
|
(None, None, None, None, ("127.0.1.1", 0)),
|
|
(None, None, None, None, ("192.168.50.10", 0)),
|
|
]
|
|
with patch("scripts.env_check.socket.gethostname", return_value="live"):
|
|
with patch("scripts.env_check.socket.getaddrinfo", return_value=fake_info):
|
|
self.assertEqual(_local_ips(), ["192.168.50.10"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|