Merge "Fix unit tests"

This commit is contained in:
Zuul 2021-09-16 04:47:29 +00:00 committed by Gerrit Code Review
commit 58a8dbbc0e
4 changed files with 15 additions and 41 deletions

View File

@ -21,20 +21,12 @@ from kuryr.lib import utils
from kuryr.tests.unit import base
mock_create = mock.MagicMock()
mock_interface = mock.MagicMock()
class TestIpvlanDriver(base.TestCase):
"""Unit tests for nested IPVLAN driver"""
@mock.patch('kuryr.lib.binding.drivers.utils._configure_container_iface')
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getattribute__',
return_value=mock_create)
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getitem__',
return_value=mock_interface)
def test_port_bind(self, mock_getitem, mock_getattribute,
mock_configure_container_iface):
@mock.patch('kuryr.lib.binding.drivers.utils.get_ipdb', mock.MagicMock())
def test_port_bind(self, mock_configure_container_iface):
fake_mtu = 1450
fake_docker_endpoint_id = utils.get_hash()
fake_docker_network_id = utils.get_hash()

View File

@ -21,20 +21,12 @@ from kuryr.lib import utils
from kuryr.tests.unit import base
mock_create = mock.MagicMock()
mock_interface = mock.MagicMock()
class TestMacvlanDriver(base.TestCase):
"""Unit tests for nested MACVLAN driver"""
@mock.patch('kuryr.lib.binding.drivers.utils._configure_container_iface')
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getattribute__',
return_value=mock_create)
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getitem__',
return_value=mock_interface)
def test_port_bind(self, mock_getitem, mock_getattribute,
mock_configure_container_iface):
@mock.patch('kuryr.lib.binding.drivers.utils.get_ipdb', mock.MagicMock())
def test_port_bind(self, mock_configure_container_iface):
fake_mtu = 1450
fake_docker_endpoint_id = utils.get_hash()
fake_docker_network_id = utils.get_hash()

View File

@ -21,22 +21,19 @@ from kuryr.lib import utils
from kuryr.tests.unit import base
mock_create = mock.MagicMock()
mock_interface = mock.MagicMock()
class TestVethDriver(base.TestCase):
"""Unit tests for veth driver"""
@mock.patch('os.path.exists', return_value=True)
@mock.patch('oslo_concurrency.processutils.execute',
return_value=('fake_stdout', 'fake_stderr'))
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getattribute__',
return_value=mock_create)
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getitem__',
return_value=mock_interface)
def test_port_bind(self, mock_getitem, mock_getattribute,
mock_execute, mock_path_exists):
@mock.patch('kuryr.lib.binding.drivers.utils.get_ipdb')
def test_port_bind(self, mock_ipdb, mock_execute, mock_path_exists):
mock_getitem = mock.MagicMock()
mock_ipdb.return_value = mock.MagicMock(
interfaces=mock.MagicMock(__getitem__=mock_getitem)
)
fake_mtu = 1450
fake_docker_endpoint_id = utils.get_hash()
fake_docker_network_id = utils.get_hash()
@ -63,7 +60,8 @@ class TestVethDriver(base.TestCase):
expect_calls = [mock.call.__enter__().set_mtu(fake_mtu),
mock.call.__enter__().up()]
mock_interface.assert_has_calls(expect_calls, any_order=True)
mock_getitem.return_value.assert_has_calls(expect_calls,
any_order=True)
mock_path_exists.assert_called_once()
mock_execute.assert_called_once()

View File

@ -21,20 +21,12 @@ from kuryr.lib import utils
from kuryr.tests.unit import base
mock_create = mock.MagicMock()
mock_interface = mock.MagicMock()
class TestVlanDriver(base.TestCase):
"""Unit tests for nested vlan driver"""
@mock.patch('kuryr.lib.binding.drivers.utils._configure_container_iface')
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getattribute__',
return_value=mock_create)
@mock.patch('pyroute2.ipdb.interfaces.InterfacesDict.__getitem__',
return_value=mock_interface)
def test_port_bind(self, mock_getitem, mock_getattribute,
mock_configure_container_iface):
@mock.patch('kuryr.lib.binding.drivers.utils.get_ipdb', mock.MagicMock())
def test_port_bind(self, mock_configure_container_iface):
fake_segmentation_id = 100
fake_docker_endpoint_id = utils.get_hash()
fake_docker_network_id = utils.get_hash()