Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected). The correct order expected by testtools is assertEqual(expected, observed). Change-Id: I57d7c242b2f2b63d71f7830fe355dbf857ffad58
This commit is contained in:
parent
8d6c6ccc14
commit
e520e21d85
52
neutron/tests/unit/agent/dhcp/test_agent.py
Normal file → Executable file
52
neutron/tests/unit/agent/dhcp/test_agent.py
Normal file → Executable file
@ -499,7 +499,7 @@ class TestDhcpAgent(base.BaseTestCase):
|
||||
dhcp._periodic_resync_helper()
|
||||
sync_state.assert_called_once_with(resync_reasons.keys())
|
||||
sleep.assert_called_once_with(dhcp.conf.resync_interval)
|
||||
self.assertEqual(len(dhcp.needs_resync_reasons), 0)
|
||||
self.assertEqual(0, len(dhcp.needs_resync_reasons))
|
||||
|
||||
def test_populate_cache_on_start_without_active_networks_support(self):
|
||||
# emul dhcp driver that doesn't support retrieving of active networks
|
||||
@ -1162,9 +1162,9 @@ class TestNetworkCache(base.BaseTestCase):
|
||||
nc.port_lookup = {fake_port1.id: fake_network.id}
|
||||
nc.remove(fake_network)
|
||||
|
||||
self.assertEqual(len(nc.cache), 0)
|
||||
self.assertEqual(len(nc.subnet_lookup), 0)
|
||||
self.assertEqual(len(nc.port_lookup), 0)
|
||||
self.assertEqual(0, len(nc.cache))
|
||||
self.assertEqual(0, len(nc.subnet_lookup))
|
||||
self.assertEqual(0, len(nc.port_lookup))
|
||||
|
||||
def test_get_network_by_id(self):
|
||||
nc = dhcp_agent.NetworkCache()
|
||||
@ -1213,7 +1213,7 @@ class TestNetworkCache(base.BaseTestCase):
|
||||
nc = dhcp_agent.NetworkCache()
|
||||
nc.put(fake_net)
|
||||
nc.put_port(fake_port2)
|
||||
self.assertEqual(len(nc.port_lookup), 2)
|
||||
self.assertEqual(2, len(nc.port_lookup))
|
||||
self.assertIn(fake_port2, fake_net.ports)
|
||||
|
||||
def test_put_port_existing(self):
|
||||
@ -1226,7 +1226,7 @@ class TestNetworkCache(base.BaseTestCase):
|
||||
nc.put(fake_net)
|
||||
nc.put_port(fake_port2)
|
||||
|
||||
self.assertEqual(len(nc.port_lookup), 2)
|
||||
self.assertEqual(2, len(nc.port_lookup))
|
||||
self.assertIn(fake_port2, fake_net.ports)
|
||||
|
||||
def test_remove_port_existing(self):
|
||||
@ -1239,7 +1239,7 @@ class TestNetworkCache(base.BaseTestCase):
|
||||
nc.put(fake_net)
|
||||
nc.remove_port(fake_port2)
|
||||
|
||||
self.assertEqual(len(nc.port_lookup), 1)
|
||||
self.assertEqual(1, len(nc.port_lookup))
|
||||
self.assertNotIn(fake_port2, fake_net.ports)
|
||||
|
||||
def test_get_port_by_id(self):
|
||||
@ -1356,7 +1356,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
dh._cleanup_stale_devices = mock.Mock()
|
||||
interface_name = dh.setup(net)
|
||||
|
||||
self.assertEqual(interface_name, 'tap12345678-12')
|
||||
self.assertEqual('tap12345678-12', interface_name)
|
||||
|
||||
plugin.assert_has_calls([
|
||||
mock.call.create_dhcp_port(
|
||||
@ -1579,7 +1579,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
mock_driver.assert_has_calls(
|
||||
[mock.call.get_device_name(fake_port)])
|
||||
|
||||
self.assertEqual(len(plugin.mock_calls), 0)
|
||||
self.assertEqual(0, len(plugin.mock_calls))
|
||||
|
||||
def test_get_device_id(self):
|
||||
fake_net = dhcp.NetModel(
|
||||
@ -1594,7 +1594,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
uuid5.return_value = '1ae5f96c-c527-5079-82ea-371a01645457'
|
||||
|
||||
dh = dhcp.DeviceManager(cfg.CONF, None)
|
||||
self.assertEqual(dh.get_device_id(fake_net), expected)
|
||||
self.assertEqual(expected, dh.get_device_id(fake_net))
|
||||
uuid5.assert_called_once_with(uuid.NAMESPACE_DNS, local_hostname)
|
||||
|
||||
def test_update(self):
|
||||
@ -1628,7 +1628,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network = FakeV4Network()
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
device.route.add_gateway.assert_called_once_with('192.168.0.1')
|
||||
|
||||
@ -1642,7 +1642,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network = FakeV4NetworkOutsideGateway()
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
device.route.add_route.assert_called_once_with('192.168.1.1',
|
||||
scope='link')
|
||||
@ -1658,7 +1658,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network.namespace = 'qdhcp-1234'
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
@ -1672,7 +1672,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network.namespace = 'qdhcp-1234'
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
device.route.delete_gateway.assert_called_once_with('192.168.0.1')
|
||||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
@ -1686,7 +1686,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network.namespace = 'qdhcp-1234'
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
device.route.delete_gateway.assert_called_once_with('192.168.0.1')
|
||||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
@ -1699,7 +1699,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network = FakeV4Network()
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
@ -1712,7 +1712,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network = FakeV4Network()
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
device.route.add_gateway.assert_called_once_with('192.168.0.1')
|
||||
|
||||
@ -1727,8 +1727,8 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network = FakeV4NetworkOutsideGateway()
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(device.route.list_onlink_routes.call_count, 2)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertEqual(2, device.route.list_onlink_routes.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
device.route.delete_route.assert_called_once_with('192.168.2.1',
|
||||
scope='link')
|
||||
@ -1749,7 +1749,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
network.subnets = [subnet2, FakeV4Subnet()]
|
||||
dh._set_default_route(network, 'tap-name')
|
||||
|
||||
self.assertEqual(device.route.get_gateway.call_count, 1)
|
||||
self.assertEqual(1, device.route.get_gateway.call_count)
|
||||
self.assertFalse(device.route.delete_gateway.called)
|
||||
device.route.add_gateway.assert_called_once_with('192.168.1.1')
|
||||
|
||||
@ -1759,23 +1759,23 @@ class TestDictModel(base.BaseTestCase):
|
||||
d = dict(a=1, b=2)
|
||||
|
||||
m = dhcp.DictModel(d)
|
||||
self.assertEqual(m.a, 1)
|
||||
self.assertEqual(m.b, 2)
|
||||
self.assertEqual(1, m.a)
|
||||
self.assertEqual(2, m.b)
|
||||
|
||||
def test_dict_has_sub_dict(self):
|
||||
d = dict(a=dict(b=2))
|
||||
m = dhcp.DictModel(d)
|
||||
self.assertEqual(m.a.b, 2)
|
||||
self.assertEqual(2, m.a.b)
|
||||
|
||||
def test_dict_contains_list(self):
|
||||
d = dict(a=[1, 2])
|
||||
|
||||
m = dhcp.DictModel(d)
|
||||
self.assertEqual(m.a, [1, 2])
|
||||
self.assertEqual([1, 2], m.a)
|
||||
|
||||
def test_dict_contains_list_of_dicts(self):
|
||||
d = dict(a=[dict(b=2), dict(c=3)])
|
||||
|
||||
m = dhcp.DictModel(d)
|
||||
self.assertEqual(m.a[0].b, 2)
|
||||
self.assertEqual(m.a[1].c, 3)
|
||||
self.assertEqual(2, m.a[0].b)
|
||||
self.assertEqual(3, m.a[1].c)
|
||||
|
Loading…
x
Reference in New Issue
Block a user