summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-11-08 08:50:45 +0100
committerChristian Breunig <christian@breunig.cc>2026-11-08 08:50:45 +0100
commit589f2e5552e8508dcc21fcc488ffc25a17e8f91f (patch)
tree9ee28b6bd8c24134283b0a97e634db0e2732813b /src/tests
parentbac758ad16b7cfa855eb977af8f50f4b9b0639d7 (diff)
downloadvyos-1x-589f2e5552e8508dcc21fcc488ffc25a17e8f91f.tar.gz
vyos-1x-589f2e5552e8508dcc21fcc488ffc25a17e8f91f.zip
utils: T9322: simplify address assignment lookup and document ValueError
The lookup for an address on all interfaces carried a copy of the zone index and VRF filtering that already exists in the lookup returning the matching interfaces. It now delegates to it, so the two cannot drift. The per-interface address match is written as a single condition, the comments are trimmed, and the docstrings state that anything but a single address raises ValueError instead of being reported as not assigned. The sflow zone index smoketest removes the dummy interface it creates, and the unit tests drop a stale task reference and a duplicate import.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_utils_network.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/tests/test_utils_network.py b/src/tests/test_utils_network.py
index 630d5dff2..48b71baf2 100644
--- a/src/tests/test_utils_network.py
+++ b/src/tests/test_utils_network.py
@@ -56,8 +56,6 @@ class TestVyOSUtilsNetwork(TestCase):
def test_is_addr_assigned_zone_index_honours_vrf(self):
# the interface named by the zone index has to be part of the VRF
# asked for, just like any other candidate
- from unittest.mock import patch
-
tmp = {'master': 'red', 'linkinfo': {'info_kind': 'dummy'}}
with patch('netifaces.interfaces', return_value=['lo', 'dum0']), patch(
'vyos.utils.network.get_interface_config', return_value=tmp
@@ -122,7 +120,7 @@ class TestVyOSUtilsNetwork(TestCase):
)
def test_is_intf_addr_assigned_rejects_invalid(self):
- # T9207: a range used to raise ValueError out of the ipaddress module
+ # anything but a single address is rejected
for addr in ['192.0.2.1-192.0.2.2', 'VyOS', '']:
with self.assertRaises(ValueError) as e:
vyos.utils.network.is_intf_addr_assigned('lo', addr)