Fix order of arguments in assertEqual
Fix incorrect order assertEqual(observed, expected) as below. assertEqual(observed, expected) => assertEqual(expected, observed) Target of this patch: manila/tests/cmd/* manila/tests/compute/* manila/db/* manila/network/* Change-Id: I6dd4f8057facc68e716b57229cbc4096af8bb152 Partial-Bug: #1259292
This commit is contained in:
parent
8e05ab9f83
commit
d3e50fd70f
@ -46,8 +46,8 @@ class ManilaCmdAllTestCase(test.TestCase):
|
||||
self.fake_log = log.getLogger.return_value
|
||||
|
||||
def _common_checks(self):
|
||||
self.assertEqual(CONF.project, 'manila')
|
||||
self.assertEqual(CONF.version, version.version_string())
|
||||
self.assertEqual('manila', CONF.project)
|
||||
self.assertEqual(version.version_string(), CONF.version)
|
||||
log.setup.assert_called_once_with(CONF, "manila")
|
||||
log.register_options.assert_called_once_with(CONF)
|
||||
log.getLogger.assert_called_once_with('manila.all')
|
||||
|
@ -40,8 +40,8 @@ class ManilaCmdApiTestCase(test.TestCase):
|
||||
process_launcher.assert_called_once_with()
|
||||
self.assertTrue(process_launcher.return_value.launch_service.called)
|
||||
self.assertTrue(process_launcher.return_value.wait.called)
|
||||
self.assertEqual(CONF.project, 'manila')
|
||||
self.assertEqual(CONF.version, version.version_string())
|
||||
self.assertEqual('manila', CONF.project)
|
||||
self.assertEqual(version.version_string(), CONF.version)
|
||||
manila_api.log.setup.assert_called_once_with(CONF, "manila")
|
||||
manila_api.log.register_options.assert_called_once_with(CONF)
|
||||
manila_api.utils.monkey_patch.assert_called_once_with()
|
||||
|
@ -279,7 +279,7 @@ class ManilaCmdManageTestCase(test.TestCase):
|
||||
def test_get_log_commands_syslog_no_log_file(self, path_exists, open):
|
||||
path_exists.return_value = False
|
||||
exit = self.assertRaises(SystemExit, self.get_log_cmds.syslog)
|
||||
self.assertEqual(exit.code, 1)
|
||||
self.assertEqual(1, exit.code)
|
||||
path_exists.assert_any_call('/var/log/syslog')
|
||||
path_exists.assert_any_call('/var/log/messages')
|
||||
|
||||
@ -332,7 +332,7 @@ class ManilaCmdManageTestCase(test.TestCase):
|
||||
exit = self.assertRaises(SystemExit, manila_manage.main)
|
||||
|
||||
self.assertTrue(register_cli_opt.called)
|
||||
self.assertEqual(exit.code, 2)
|
||||
self.assertEqual(2, exit.code)
|
||||
|
||||
@mock.patch('oslo_config.cfg.ConfigOpts.__call__')
|
||||
@mock.patch('oslo_log.log.register_options')
|
||||
@ -353,7 +353,7 @@ class ManilaCmdManageTestCase(test.TestCase):
|
||||
sys.argv[1:], project='manila',
|
||||
version=version.version_string())
|
||||
self.assertFalse(log_setup.called)
|
||||
self.assertEqual(exit.code, 2)
|
||||
self.assertEqual(2, exit.code)
|
||||
|
||||
@mock.patch('oslo_config.cfg.ConfigOpts.__call__')
|
||||
@mock.patch('oslo_config.cfg.ConfigOpts.register_cli_opt')
|
||||
|
@ -35,8 +35,8 @@ class ManilaCmdSchedulerTestCase(test.TestCase):
|
||||
|
||||
manila_scheduler.main()
|
||||
|
||||
self.assertEqual(CONF.project, 'manila')
|
||||
self.assertEqual(CONF.version, version.version_string())
|
||||
self.assertEqual('manila', CONF.project)
|
||||
self.assertEqual(version.version_string(), CONF.version)
|
||||
manila_scheduler.log.setup.assert_called_once_with(CONF, "manila")
|
||||
manila_scheduler.log.register_options.assert_called_once_with(CONF)
|
||||
manila_scheduler.utils.monkey_patch.assert_called_once_with()
|
||||
|
@ -102,7 +102,7 @@ class NovaApiTestCase(test.TestCase):
|
||||
def test_server_create(self):
|
||||
result = self.api.server_create(self.ctx, 'server_name', 'fake_image',
|
||||
'fake_flavor', None, None, None)
|
||||
self.assertEqual(result['id'], 'created_id')
|
||||
self.assertEqual('created_id', result['id'])
|
||||
|
||||
def test_server_delete(self):
|
||||
self.mock_object(self.novaclient.servers, 'delete')
|
||||
@ -202,9 +202,9 @@ class NovaApiTestCase(test.TestCase):
|
||||
self.mock_object(cinder, 'cinderclient',
|
||||
mock.Mock(return_value=self.novaclient))
|
||||
result = self.api.instance_volumes_list(self.ctx, 'instance_id')
|
||||
self.assertEqual(len(result), 2)
|
||||
self.assertEqual(result[0].id, 'id1')
|
||||
self.assertEqual(result[1].id, 'id2')
|
||||
self.assertEqual(2, len(result))
|
||||
self.assertEqual('id1', result[0].id)
|
||||
self.assertEqual('id2', result[1].id)
|
||||
|
||||
def test_server_update(self):
|
||||
self.mock_object(self.novaclient.servers, 'update')
|
||||
|
@ -190,7 +190,7 @@ class TestManilaMigrationsMySQL(ManilaMigrationsCheckers,
|
||||
text(noninnodb_query),
|
||||
database=self.engine.url.database
|
||||
).scalar()
|
||||
self.assertEqual(count, 0, "%d non InnoDB tables created" % count)
|
||||
self.assertEqual(0, count, "%d non InnoDB tables created" % count)
|
||||
|
||||
|
||||
class TestManilaMigrationsPostgreSQL(
|
||||
|
@ -47,7 +47,7 @@ security_service_dict = {
|
||||
class BaseDatabaseAPITestCase(test.TestCase):
|
||||
def _check_fields(self, expected, actual):
|
||||
for key in expected:
|
||||
self.assertEqual(actual[key], expected[key])
|
||||
self.assertEqual(expected[key], actual[key])
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@ -728,8 +728,8 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
self.share_nw_dict)
|
||||
|
||||
self._check_fields(expected=self.share_nw_dict, actual=result)
|
||||
self.assertEqual(len(result['share_instances']), 0)
|
||||
self.assertEqual(len(result['security_services']), 0)
|
||||
self.assertEqual(0, len(result['share_instances']))
|
||||
self.assertEqual(0, len(result['security_services']))
|
||||
|
||||
def test_create_two_networks_in_different_tenants(self):
|
||||
share_nw_dict2 = self.share_nw_dict.copy()
|
||||
@ -767,8 +767,8 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self._check_fields(expected=self.share_nw_dict, actual=result)
|
||||
self.assertEqual(len(result['share_instances']), 0)
|
||||
self.assertEqual(len(result['security_services']), 0)
|
||||
self.assertEqual(0, len(result['share_instances']))
|
||||
self.assertEqual(0, len(result['security_services']))
|
||||
|
||||
@ddt.data([{'id': 'fake share id1'}],
|
||||
[{'id': 'fake share id1'}, {'id': 'fake share id2'}],)
|
||||
@ -784,7 +784,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
result = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self.assertEqual(len(result['share_instances']), len(shares))
|
||||
self.assertEqual(len(shares), len(result['share_instances']))
|
||||
for index, share_instance in enumerate(share_instances):
|
||||
self.assertEqual(
|
||||
share_instance['share_network_id'],
|
||||
@ -806,8 +806,9 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
result = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self.assertEqual(len(result['security_services']),
|
||||
len(security_services))
|
||||
self.assertEqual(len(security_services),
|
||||
len(result['security_services']))
|
||||
|
||||
for index, service in enumerate(security_services):
|
||||
self._check_fields(expected=service,
|
||||
actual=result['security_services'][index])
|
||||
@ -843,7 +844,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
result_get = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self.assertEqual(result_update['name'], new_name)
|
||||
self.assertEqual(new_name, result_update['name'])
|
||||
self._check_fields(expected=dict(six.iteritems(result_update)),
|
||||
actual=dict(six.iteritems(result_get)))
|
||||
|
||||
@ -869,7 +870,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
|
||||
result = db_api.share_network_get_all(self.fake_context)
|
||||
|
||||
self.assertEqual(len(result), len(share_networks))
|
||||
self.assertEqual(len(share_networks), len(result))
|
||||
for index, net in enumerate(share_networks):
|
||||
self._check_fields(expected=net, actual=result[index])
|
||||
|
||||
@ -885,7 +886,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
self.fake_context,
|
||||
share_nw_dict2['project_id'])
|
||||
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertEqual(1, len(result))
|
||||
self._check_fields(expected=share_nw_dict2, actual=result[0])
|
||||
|
||||
def test_add_security_service(self):
|
||||
@ -973,7 +974,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
|
||||
share_nw_ref = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
self.assertEqual(len(share_nw_ref['security_services']), 0)
|
||||
self.assertEqual(0, len(share_nw_ref['security_services']))
|
||||
|
||||
def test_remove_security_service_not_found_01(self):
|
||||
security_service_id = 'unknown security service'
|
||||
@ -1024,7 +1025,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
result = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self.assertEqual(len(result['security_services']), 0)
|
||||
self.assertEqual(0, len(result['security_services']))
|
||||
|
||||
def test_shares_relation(self):
|
||||
share_dict = {'id': 'fake share id1'}
|
||||
@ -1035,7 +1036,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
result = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self.assertEqual(len(result['share_instances']), 0)
|
||||
self.assertEqual(0, len(result['share_instances']))
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@ -1051,7 +1052,7 @@ class SecurityServiceDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
|
||||
def _check_expected_fields(self, result, expected):
|
||||
for key in expected:
|
||||
self.assertEqual(result[key], expected[key])
|
||||
self.assertEqual(expected[key], result[key])
|
||||
|
||||
def test_create(self):
|
||||
result = db_api.security_service_create(self.fake_context,
|
||||
@ -1135,7 +1136,7 @@ class SecurityServiceDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
def test_get_all_no_records(self):
|
||||
result = db_api.security_service_get_all(self.fake_context)
|
||||
|
||||
self.assertEqual(len(result), 0)
|
||||
self.assertEqual(0, len(result))
|
||||
|
||||
@ddt.data(1, 2)
|
||||
def test_get_all(self, records_count):
|
||||
@ -1150,7 +1151,7 @@ class SecurityServiceDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
|
||||
result = db_api.security_service_get_all(self.fake_context)
|
||||
|
||||
self.assertEqual(len(result), len(services))
|
||||
self.assertEqual(len(services), len(result))
|
||||
for index, service in enumerate(services):
|
||||
self._check_fields(expected=service, actual=result[index])
|
||||
|
||||
@ -1165,7 +1166,7 @@ class SecurityServiceDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
|
||||
result = db_api.security_service_get_all(self.fake_context)
|
||||
|
||||
self.assertEqual(len(result), 2)
|
||||
self.assertEqual(2, len(result))
|
||||
|
||||
def test_get_all_by_project(self):
|
||||
dict1 = security_service_dict
|
||||
@ -1181,14 +1182,14 @@ class SecurityServiceDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
self.fake_context,
|
||||
dict1['project_id'])
|
||||
|
||||
self.assertEqual(len(result1), 1)
|
||||
self.assertEqual(1, len(result1))
|
||||
self._check_expected_fields(result1[0], dict1)
|
||||
|
||||
result2 = db_api.security_service_get_all_by_project(
|
||||
self.fake_context,
|
||||
dict2['project_id'])
|
||||
|
||||
self.assertEqual(len(result2), 1)
|
||||
self.assertEqual(1, len(result2))
|
||||
self._check_expected_fields(result2[0], dict2)
|
||||
|
||||
|
||||
@ -1204,9 +1205,9 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
expected = db_utils.create_share_server()
|
||||
server = db_api.share_server_get(self.ctxt, expected['id'])
|
||||
self.assertEqual(expected['id'], server['id'])
|
||||
self.assertEqual(server.share_network_id, expected.share_network_id)
|
||||
self.assertEqual(server.host, expected.host)
|
||||
self.assertEqual(server.status, expected.status)
|
||||
self.assertEqual(expected.share_network_id, server.share_network_id)
|
||||
self.assertEqual(expected.host, server.host)
|
||||
self.assertEqual(expected.status, server.status)
|
||||
|
||||
def test_get_not_found(self):
|
||||
fake_id = 'FAKE_UUID'
|
||||
@ -1224,8 +1225,8 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
server = db_utils.create_share_server()
|
||||
num_records = len(db_api.share_server_get_all(self.ctxt))
|
||||
db_api.share_server_delete(self.ctxt, server['id'])
|
||||
self.assertEqual(len(db_api.share_server_get_all(self.ctxt)),
|
||||
num_records - 1)
|
||||
self.assertEqual(num_records - 1,
|
||||
len(db_api.share_server_get_all(self.ctxt)))
|
||||
|
||||
def test_delete_not_found(self):
|
||||
fake_id = 'FAKE_UUID'
|
||||
@ -1243,10 +1244,10 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
updated_server = db_api.share_server_update(self.ctxt, server['id'],
|
||||
update)
|
||||
self.assertEqual(server['id'], updated_server['id'])
|
||||
self.assertEqual(updated_server.share_network_id,
|
||||
update['share_network_id'])
|
||||
self.assertEqual(updated_server.host, update['host'])
|
||||
self.assertEqual(updated_server.status, update['status'])
|
||||
self.assertEqual(update['share_network_id'],
|
||||
updated_server.share_network_id)
|
||||
self.assertEqual(update['host'], updated_server.host)
|
||||
self.assertEqual(update['status'], updated_server.status)
|
||||
|
||||
def test_update_not_found(self):
|
||||
fake_id = 'FAKE_UUID'
|
||||
@ -1278,7 +1279,7 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
self.ctxt,
|
||||
host='host1',
|
||||
share_net_id='1')
|
||||
self.assertEqual(servers[0]['id'], valid['id'])
|
||||
self.assertEqual(valid['id'], servers[0]['id'])
|
||||
|
||||
def test_get_all_by_host_and_share_net_not_found(self):
|
||||
self.assertRaises(
|
||||
@ -1304,18 +1305,18 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
servers = db_api.share_server_get_all(self.ctxt)
|
||||
self.assertEqual(len(servers), 0)
|
||||
self.assertEqual(0, len(servers))
|
||||
|
||||
to_delete = db_utils.create_share_server(**srv1)
|
||||
db_utils.create_share_server(**srv2)
|
||||
db_utils.create_share_server(**srv3)
|
||||
|
||||
servers = db_api.share_server_get_all(self.ctxt)
|
||||
self.assertEqual(len(servers), 3)
|
||||
self.assertEqual(3, len(servers))
|
||||
|
||||
db_api.share_server_delete(self.ctxt, to_delete['id'])
|
||||
servers = db_api.share_server_get_all(self.ctxt)
|
||||
self.assertEqual(len(servers), 2)
|
||||
self.assertEqual(2, len(servers))
|
||||
|
||||
def test_backend_details_set(self):
|
||||
details = {
|
||||
@ -1351,10 +1352,10 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
db_api.share_server_backend_details_set(self.ctxt, srv_id, details)
|
||||
server = db_api.share_server_get(self.ctxt, srv_id)
|
||||
self.assertEqual(srv_id, server['id'])
|
||||
self.assertEqual(server.share_network_id, values['share_network_id'])
|
||||
self.assertEqual(server.host, values['host'])
|
||||
self.assertEqual(server.status, values['status'])
|
||||
self.assertDictMatch(details, server['backend_details'])
|
||||
self.assertEqual(values['share_network_id'], server.share_network_id)
|
||||
self.assertEqual(values['host'], server.host)
|
||||
self.assertEqual(values['status'], server.status)
|
||||
self.assertDictMatch(server['backend_details'], details)
|
||||
self.assertTrue('backend_details' in server.to_dict())
|
||||
|
||||
def test_delete_with_details(self):
|
||||
@ -1365,8 +1366,8 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
|
||||
num_records = len(db_api.share_server_get_all(self.ctxt))
|
||||
db_api.share_server_delete(self.ctxt, server['id'])
|
||||
self.assertEqual(len(db_api.share_server_get_all(self.ctxt)),
|
||||
num_records - 1)
|
||||
self.assertEqual(num_records - 1,
|
||||
len(db_api.share_server_get_all(self.ctxt)))
|
||||
|
||||
|
||||
class ServiceDatabaseAPITestCase(test.TestCase):
|
||||
|
@ -215,7 +215,7 @@ class TestBridgeInterfaceDriver(TestBase):
|
||||
'tap0',
|
||||
'aa:bb:cc:dd:ee:ff')
|
||||
self.ip_dev.assert_has_calls([])
|
||||
self.assertEqual(log.call_count, 1)
|
||||
self.assertEqual(1, log.call_count)
|
||||
|
||||
def test_unplug_no_device(self):
|
||||
self.device_exists.return_value = False
|
||||
@ -224,7 +224,7 @@ class TestBridgeInterfaceDriver(TestBase):
|
||||
br = interface.BridgeInterfaceDriver()
|
||||
br.unplug('tap0')
|
||||
[mock.call(), mock.call('tap0'), mock.call().link.delete()]
|
||||
self.assertEqual(log.error.call_count, 1)
|
||||
self.assertEqual(1, log.error.call_count)
|
||||
|
||||
def test_unplug(self):
|
||||
self.device_exists.return_value = True
|
||||
|
@ -160,34 +160,34 @@ class TestIpWrapper(test.TestCase):
|
||||
def test_get_devices(self):
|
||||
self.execute.return_value = '\n'.join(LINK_SAMPLE)
|
||||
retval = ip_lib.IPWrapper().get_devices()
|
||||
self.assertEqual(retval,
|
||||
[ip_lib.IPDevice('lo'),
|
||||
self.assertEqual([ip_lib.IPDevice('lo'),
|
||||
ip_lib.IPDevice('eth0'),
|
||||
ip_lib.IPDevice('br-int'),
|
||||
ip_lib.IPDevice('gw-ddc717df-49'),
|
||||
ip_lib.IPDevice('eth0.50')])
|
||||
ip_lib.IPDevice('eth0.50')],
|
||||
retval)
|
||||
|
||||
self.execute.assert_called_once_with('o', 'link', ('list',), None)
|
||||
|
||||
def test_get_devices_malformed_line(self):
|
||||
self.execute.return_value = '\n'.join(LINK_SAMPLE + ['gibberish'])
|
||||
retval = ip_lib.IPWrapper().get_devices()
|
||||
self.assertEqual(retval,
|
||||
[ip_lib.IPDevice('lo'),
|
||||
self.assertEqual([ip_lib.IPDevice('lo'),
|
||||
ip_lib.IPDevice('eth0'),
|
||||
ip_lib.IPDevice('br-int'),
|
||||
ip_lib.IPDevice('gw-ddc717df-49'),
|
||||
ip_lib.IPDevice('eth0.50')])
|
||||
ip_lib.IPDevice('eth0.50')],
|
||||
retval)
|
||||
|
||||
self.execute.assert_called_once_with('o', 'link', ('list',), None)
|
||||
|
||||
def test_get_namespaces(self):
|
||||
self.execute.return_value = '\n'.join(NETNS_SAMPLE)
|
||||
retval = ip_lib.IPWrapper.get_namespaces()
|
||||
self.assertEqual(retval,
|
||||
['12345678-1234-5678-abcd-1234567890ab',
|
||||
self.assertEqual(['12345678-1234-5678-abcd-1234567890ab',
|
||||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
|
||||
'cccccccc-cccc-cccc-cccc-cccccccccccc'])
|
||||
'cccccccc-cccc-cccc-cccc-cccccccccccc'],
|
||||
retval)
|
||||
|
||||
self.execute.assert_called_once_with('', 'netns', ('list',))
|
||||
|
||||
@ -217,8 +217,8 @@ class TestIpWrapper(test.TestCase):
|
||||
|
||||
def test_get_device(self):
|
||||
dev = ip_lib.IPWrapper('ns').device('eth0')
|
||||
self.assertEqual(dev.namespace, 'ns')
|
||||
self.assertEqual(dev.name, 'eth0')
|
||||
self.assertEqual('ns', dev.namespace)
|
||||
self.assertEqual('eth0', dev.name)
|
||||
|
||||
def test_ensure_namespace(self):
|
||||
with mock.patch.object(ip_lib, 'IPDevice') as ip_dev:
|
||||
@ -237,7 +237,7 @@ class TestIpWrapper(test.TestCase):
|
||||
ip_ns_cmd.exists.return_value = True
|
||||
ns = ip_lib.IPWrapper().ensure_namespace('ns')
|
||||
self.assertFalse(self.execute.called)
|
||||
self.assertEqual(ns.namespace, 'ns')
|
||||
self.assertEqual('ns', ns.namespace)
|
||||
|
||||
def test_namespace_is_empty_no_devices(self):
|
||||
ip = ip_lib.IPWrapper('ns')
|
||||
@ -264,7 +264,7 @@ class TestIpWrapper(test.TestCase):
|
||||
ip_ns_cmd_cls.assert_has_calls([mock.call().exists('ns')])
|
||||
self.assertNotIn(mock.call().delete('ns'),
|
||||
ip_ns_cmd_cls.return_value.mock_calls)
|
||||
self.assertEqual(mock_is_empty.mock_calls, [])
|
||||
self.assertEqual([], mock_is_empty.mock_calls)
|
||||
|
||||
def test_garbage_collect_namespace_existing_empty_ns(self):
|
||||
with mock.patch.object(ip_lib, 'IpNetnsCommand') as ip_ns_cmd_cls:
|
||||
@ -300,7 +300,7 @@ class TestIpWrapper(test.TestCase):
|
||||
mock_is_empty.assert_called_once_with()
|
||||
expected = [mock.call(ip),
|
||||
mock.call().exists('ns')]
|
||||
self.assertEqual(ip_ns_cmd_cls.mock_calls, expected)
|
||||
self.assertEqual(expected, ip_ns_cmd_cls.mock_calls)
|
||||
self.assertNotIn(mock.call().delete('ns'),
|
||||
ip_ns_cmd_cls.mock_calls)
|
||||
|
||||
@ -312,7 +312,7 @@ class TestIpWrapper(test.TestCase):
|
||||
def test_add_device_to_namespace_is_none(self):
|
||||
dev = mock.Mock()
|
||||
ip_lib.IPWrapper().add_device_to_namespace(dev)
|
||||
self.assertEqual(dev.mock_calls, [])
|
||||
self.assertEqual([], dev.mock_calls)
|
||||
|
||||
|
||||
class TestIPDevice(test.TestCase):
|
||||
@ -341,7 +341,7 @@ class TestIPDevice(test.TestCase):
|
||||
self.assertNotEqual(dev1, None)
|
||||
|
||||
def test_str(self):
|
||||
self.assertEqual(str(ip_lib.IPDevice('tap0')), 'tap0')
|
||||
self.assertEqual('tap0', str(ip_lib.IPDevice('tap0')))
|
||||
|
||||
|
||||
class TestIPCommandBase(test.TestCase):
|
||||
@ -381,7 +381,7 @@ class TestIPDeviceCommandBase(test.TestCase):
|
||||
self.ip_cmd.COMMAND = 'foo'
|
||||
|
||||
def test_name_property(self):
|
||||
self.assertEqual(self.ip_cmd.name, 'eth0')
|
||||
self.assertEqual('eth0', self.ip_cmd.name)
|
||||
|
||||
|
||||
class TestIPCmdBase(test.TestCase):
|
||||
@ -426,12 +426,12 @@ class TestIpLinkCommand(TestIPCmdBase):
|
||||
def test_set_netns(self):
|
||||
self.link_cmd.set_netns('foo')
|
||||
self._assert_sudo([], ('set', 'eth0', 'netns', 'foo'))
|
||||
self.assertEqual(self.parent.namespace, 'foo')
|
||||
self.assertEqual('foo', self.parent.namespace)
|
||||
|
||||
def test_set_name(self):
|
||||
self.link_cmd.set_name('tap1')
|
||||
self._assert_sudo([], ('set', 'eth0', 'name', 'tap1'))
|
||||
self.assertEqual(self.parent.name, 'tap1')
|
||||
self.assertEqual('tap1', self.parent.name)
|
||||
|
||||
def test_set_alias(self):
|
||||
self.link_cmd.set_alias('openvswitch')
|
||||
@ -443,27 +443,27 @@ class TestIpLinkCommand(TestIPCmdBase):
|
||||
|
||||
def test_address_property(self):
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.address, 'cc:dd:ee:ff:ab:cd')
|
||||
self.assertEqual('cc:dd:ee:ff:ab:cd', self.link_cmd.address)
|
||||
|
||||
def test_mtu_property(self):
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.mtu, 1500)
|
||||
self.assertEqual(1500, self.link_cmd.mtu)
|
||||
|
||||
def test_qdisc_property(self):
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.qdisc, 'mq')
|
||||
self.assertEqual('mq', self.link_cmd.qdisc)
|
||||
|
||||
def test_qlen_property(self):
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.qlen, 1000)
|
||||
self.assertEqual(1000, self.link_cmd.qlen)
|
||||
|
||||
def test_alias_property(self):
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.alias, 'openvswitch')
|
||||
self.assertEqual('openvswitch', self.link_cmd.alias)
|
||||
|
||||
def test_state_property(self):
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.state, 'UP')
|
||||
self.assertEqual('UP', self.link_cmd.state)
|
||||
|
||||
def test_settings_property(self):
|
||||
expected = {'mtu': 1500,
|
||||
@ -474,7 +474,7 @@ class TestIpLinkCommand(TestIPCmdBase):
|
||||
'link/ether': 'cc:dd:ee:ff:ab:cd',
|
||||
'alias': 'openvswitch'}
|
||||
self.parent._execute = mock.Mock(return_value=LINK_SAMPLE[1])
|
||||
self.assertEqual(self.link_cmd.attributes, expected)
|
||||
self.assertEqual(expected, self.link_cmd.attributes)
|
||||
self._assert_call('o', ('show', 'eth0'))
|
||||
|
||||
|
||||
@ -532,7 +532,7 @@ class TestIpAddrCommand(TestIPCmdBase):
|
||||
|
||||
for test_case in test_cases:
|
||||
self.parent._run = mock.Mock(return_value=test_case)
|
||||
self.assertEqual(self.addr_cmd.list(), expected)
|
||||
self.assertEqual(expected, self.addr_cmd.list())
|
||||
self._assert_call([], ('show', 'tap0'))
|
||||
|
||||
def test_list_filtered(self):
|
||||
@ -546,8 +546,8 @@ class TestIpAddrCommand(TestIPCmdBase):
|
||||
for test_case in test_cases:
|
||||
output = '\n'.join(test_case.split('\n')[0:4])
|
||||
self.parent._run.return_value = output
|
||||
self.assertEqual(self.addr_cmd.list('global',
|
||||
filters=['permanent']), expected)
|
||||
self.assertEqual(expected, self.addr_cmd.list('global',
|
||||
filters=['permanent']))
|
||||
self._assert_call([], ('show', 'tap0', 'permanent', 'scope',
|
||||
'global'))
|
||||
|
||||
@ -588,8 +588,8 @@ class TestIpRouteCommand(TestIPCmdBase):
|
||||
'expected': {'gateway': '10.35.19.254'}}]
|
||||
for test_case in test_cases:
|
||||
self.parent._run = mock.Mock(return_value=test_case['sample'])
|
||||
self.assertEqual(self.route_cmd.get_gateway(),
|
||||
test_case['expected'])
|
||||
self.assertEqual(test_case['expected'],
|
||||
self.route_cmd.get_gateway())
|
||||
|
||||
def test_pullup_route(self):
|
||||
# interface is not the first in the list - requires
|
||||
@ -617,7 +617,7 @@ class TestIpRouteCommand(TestIPCmdBase):
|
||||
self.parent._run = mock.Mock(side_effect=pullup_side_effect)
|
||||
self.route_cmd.pullup_route('tap1d7888a7-10')
|
||||
# Check two calls - device get and subnet get
|
||||
self.assertEqual(len(self.parent._run.mock_calls), 2)
|
||||
self.assertEqual(2, len(self.parent._run.mock_calls))
|
||||
|
||||
|
||||
class TestIpNetnsCommand(TestIPCmdBase):
|
||||
@ -629,7 +629,7 @@ class TestIpNetnsCommand(TestIPCmdBase):
|
||||
def test_add_namespace(self):
|
||||
ns = self.netns_cmd.add('ns')
|
||||
self._assert_sudo([], ('add', 'ns'), force_root_namespace=True)
|
||||
self.assertEqual(ns.namespace, 'ns')
|
||||
self.assertEqual('ns', ns.namespace)
|
||||
|
||||
def test_delete_namespace(self):
|
||||
with mock.patch('manila.utils.execute'):
|
||||
|
@ -63,7 +63,7 @@ class OVS_Lib_Test(test.TestCase):
|
||||
vif_id = match.group('vif_id')
|
||||
port_name = match.group('port_name')
|
||||
ofport = int(match.group('ofport'))
|
||||
self.assertEqual(vif_mac, 'fa:16:3e:23:5b:f2')
|
||||
self.assertEqual(vif_id, '5c1321a7-c73f-4a77-95e6-9f86402e5c8f')
|
||||
self.assertEqual(port_name, 'dhc5c1321a7-c7')
|
||||
self.assertEqual(ofport, 2)
|
||||
self.assertEqual('fa:16:3e:23:5b:f2', vif_mac)
|
||||
self.assertEqual('5c1321a7-c73f-4a77-95e6-9f86402e5c8f', vif_id)
|
||||
self.assertEqual('dhc5c1321a7-c7', port_name)
|
||||
self.assertEqual(2, ofport)
|
||||
|
@ -132,19 +132,19 @@ class NeutronApiTest(test.TestCase):
|
||||
port = self.neutron_api.create_port(**port_args)
|
||||
|
||||
# Verify results
|
||||
self.assertEqual(port['tenant_id'], port_args['tenant_id'])
|
||||
self.assertEqual(port['network_id'], port_args['network_id'])
|
||||
self.assertEqual(port['binding:host_id'], port_args['host_id'])
|
||||
self.assertEqual(port['fixed_ips'][0]['subnet_id'],
|
||||
port_args['subnet_id'])
|
||||
self.assertEqual(port['fixed_ips'][0]['ip_address'],
|
||||
port_args['fixed_ip'])
|
||||
self.assertEqual(port['device_owner'], port_args['device_owner'])
|
||||
self.assertEqual(port['device_id'], port_args['device_id'])
|
||||
self.assertEqual(port['mac_address'], port_args['mac_address'])
|
||||
self.assertEqual(port['security_groups'],
|
||||
port_args['security_group_ids'])
|
||||
self.assertEqual(port['extra_dhcp_opts'], port_args['dhcp_opts'])
|
||||
self.assertEqual(port_args['tenant_id'], port['tenant_id'])
|
||||
self.assertEqual(port_args['network_id'], port['network_id'])
|
||||
self.assertEqual(port_args['host_id'], port['binding:host_id'])
|
||||
self.assertEqual(port_args['subnet_id'],
|
||||
port['fixed_ips'][0]['subnet_id'])
|
||||
self.assertEqual(port_args['fixed_ip'],
|
||||
port['fixed_ips'][0]['ip_address'])
|
||||
self.assertEqual(port_args['device_owner'], port['device_owner'])
|
||||
self.assertEqual(port_args['device_id'], port['device_id'])
|
||||
self.assertEqual(port_args['mac_address'], port['mac_address'])
|
||||
self.assertEqual(port_args['security_group_ids'],
|
||||
port['security_groups'])
|
||||
self.assertEqual(port_args['dhcp_opts'], port['extra_dhcp_opts'])
|
||||
self.neutron_api._has_port_binding_extension.assert_called_once_with()
|
||||
self.assertTrue(clientv20.Client.called)
|
||||
|
||||
@ -158,9 +158,9 @@ class NeutronApiTest(test.TestCase):
|
||||
port = self.neutron_api.create_port(**port_args)
|
||||
|
||||
# Verify results
|
||||
self.assertEqual(port['tenant_id'], port_args['tenant_id'])
|
||||
self.assertEqual(port['network_id'],
|
||||
port_args['network_id'])
|
||||
self.assertEqual(port_args['tenant_id'], port['tenant_id'])
|
||||
self.assertEqual(port_args['network_id'],
|
||||
port['network_id'])
|
||||
self.neutron_api._has_port_binding_extension.assert_called_once_with()
|
||||
self.assertTrue(clientv20.Client.called)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user