This commit is contained in:
Andrew Pimenov 2026-10-07 06:55:31 +03:00 • committed by GitHub
commit fafcb1b271
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ from __future__ import annotations
import socket import socket
from netsleuth.iface import ( from netsleuth.iface import (
_match_iface_name,
available_interfaces_hint, available_interfaces_hint,
resolve_bind_target, resolve_bind_target,
usable_addresses, usable_addresses,
@ -17,6 +18,30 @@ def up(**kw) -> dict[str, bool]:
return kw return kw
def test_match_iface_name_exact():
assert _match_iface_name("eth0", ["eth0", "eth1"]) == "eth0"
def test_match_iface_name_case_insensitive_exact():
assert _match_iface_name("ETH0", ["eth0", "eth1"]) == "eth0"
def test_match_iface_name_case_insensitive_exact_multiple():
assert _match_iface_name("EtH0", ["eth0", "ETH0"]) == ["eth0", "ETH0"]
def test_match_iface_name_substring():
assert _match_iface_name("eth", ["my-eth0-iface", "wlan0"]) == "my-eth0-iface"
def test_match_iface_name_substring_multiple():
assert _match_iface_name("eth", ["eth0", "eth1"]) == ["eth0", "eth1"]
def test_match_iface_name_no_match():
assert _match_iface_name("eth", ["wlan0", "lo"]) == []
def test_usable_addresses_picks_first_non_loopback_v4_and_v6(): def test_usable_addresses_picks_first_non_loopback_v4_and_v6():
v4, v6 = usable_addresses( v4, v6 = usable_addresses(
[ [