From: Sphoorti Joglekar Date: Fri, 14 Mar 2014 12:52:43 +0000 (+0530) Subject: Add unit test for add_vxlan in test_linux_ip_lib X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6120258739d2fd461479ba85132cf632de891b6c;p=openstack-build%2Fneutron-build.git Add unit test for add_vxlan in test_linux_ip_lib This patch adds unit tests for the add_vxlan function in the test_linux_ip_lib.py file. Fixes bug: 1291974 Change-Id: I0238bedab7a3566aff1115a091ada494a01d2e02 (cherry picked from commit dd52ddb1e9322b3985ceba2db842e8201220f67f) --- diff --git a/neutron/tests/unit/test_linux_ip_lib.py b/neutron/tests/unit/test_linux_ip_lib.py index ea23c8549..7eb58ad7b 100644 --- a/neutron/tests/unit/test_linux_ip_lib.py +++ b/neutron/tests/unit/test_linux_ip_lib.py @@ -371,6 +371,32 @@ class TestIpWrapper(base.BaseTestCase): self.assertNotIn(mock.call().delete('ns'), ip_ns_cmd_cls.mock_calls) + def test_add_vxlan_valid_port_length(self): + retval = ip_lib.IPWrapper('sudo').add_vxlan('vxlan0', 'vni0', + group='group0', + dev='dev0', ttl='ttl0', + tos='tos0', + local='local0', proxy=True, + port=('1', '2')) + self.assertIsInstance(retval, ip_lib.IPDevice) + self.assertEqual(retval.name, 'vxlan0') + self.execute.assert_called_once_with('', 'link', + ['add', 'vxlan0', 'type', + 'vxlan', 'id', 'vni0', 'group', + 'group0', 'dev', 'dev0', + 'ttl', 'ttl0', 'tos', 'tos0', + 'local', 'local0', 'proxy', + 'port', '1', '2'], + 'sudo', None) + + def test_add_vxlan_invalid_port_length(self): + wrapper = ip_lib.IPWrapper('sudo') + self.assertRaises(exceptions.NetworkVxlanPortRangeError, + wrapper.add_vxlan, 'vxlan0', 'vni0', group='group0', + dev='dev0', ttl='ttl0', tos='tos0', + local='local0', proxy=True, + port=('1', '2', '3')) + def test_add_device_to_namespace(self): dev = mock.Mock() ip_lib.IPWrapper('sudo', 'ns').add_device_to_namespace(dev)