mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-11 02:12:04 +03:00
test: add tests for _match_iface_name
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
8c99ac78b7
commit
863e7366bb
1 changed files with 25 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
import socket
|
||||
|
||||
from netsleuth.iface import (
|
||||
_match_iface_name,
|
||||
available_interfaces_hint,
|
||||
resolve_bind_target,
|
||||
usable_addresses,
|
||||
|
|
@ -17,6 +18,30 @@ def up(**kw) -> dict[str, bool]:
|
|||
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():
|
||||
v4, v6 = usable_addresses(
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue