Fix tests involving pyroute2.netns module

pyroute2 0.6.11 did some further refactoring of their module imports,
adapt some mocks to that the tests work with both the older and the new
versions.

Change-Id: I00c1b1e81c33cf93372dec21f4a9f409d784a160
This commit is contained in:
Dr. Jens Harbott 2022-06-08 19:46:13 +02:00
parent e44dbe98e8
commit fe4fa55642
1 changed files with 3 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import pyroute2
from pyroute2.netlink.rtnl import ifinfmsg
from pyroute2.netlink.rtnl import ndmsg
from pyroute2 import NetlinkError
from pyroute2 import netns
import testtools
from neutron.agent.common import utils # noqa
@ -201,7 +202,7 @@ class TestIpWrapper(base.BaseTestCase):
netns_name='foo')
self.assertEqual([], ip_lib.IPWrapper(namespace='foo').get_devices())
@mock.patch.object(pyroute2.netns, 'listnetns')
@mock.patch.object(netns, 'listnetns')
@mock.patch.object(priv_lib, 'list_netns')
def test_get_namespaces_non_root(self, priv_listnetns, listnetns):
self.config(group='AGENT', use_helper_for_ns_read=False)
@ -214,7 +215,7 @@ class TestIpWrapper(base.BaseTestCase):
self.assertEqual(1, listnetns.call_count)
self.assertFalse(priv_listnetns.called)
@mock.patch.object(pyroute2.netns, 'listnetns')
@mock.patch.object(netns, 'listnetns')
@mock.patch.object(priv_lib, 'list_netns')
def test_get_namespaces_root(self, priv_listnetns, listnetns):
self.config(group='AGENT', use_helper_for_ns_read=True)