From 589f2e5552e8508dcc21fcc488ffc25a17e8f91f Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 8 Nov 2026 08:50:45 +0100 Subject: 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. --- src/tests/test_utils_network.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/tests') 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) -- cgit v1.2.3