summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangyangyang <zhangyangyang@unionpay.com>2017-09-12 15:44:20 +0800
committerzhangyangyang <zhangyangyang@unionpay.com>2017-09-12 15:50:42 +0800
commit29f42fa5dedd5153ee106b653235162a46ef4bb7 (patch)
tree1d1798bc73bc59863462c909bffbff2f91367410
parent0161dde79660a248742e41e67f92ed13af561dd7 (diff)
change assert(Not)Equals to assert(Not)Equal
According to http://docs.python.org/2/library/unittest.html assert(Not)Equals is a deprecated alias of assert(Not)Equal. Change-Id: Iac2d5eefe47b96efc787c6eca5ca014ca3b3910c Closes-Bug: #1329757
Notes
Notes (review): Verified+1: Canonical CI <uosci-testing-bot@ubuntu.com> Code-Review+2: James Page <james.page@canonical.com> Workflow+1: James Page <james.page@canonical.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 12 Sep 2017 21:55:46 +0000 Reviewed-on: https://review.openstack.org/502907 Project: openstack/charm-nova-cloud-controller Branch: refs/heads/master
-rw-r--r--unit_tests/test_nova_cc_hooks.py18
-rw-r--r--unit_tests/test_nova_cc_utils.py66
2 files changed, 42 insertions, 42 deletions
diff --git a/unit_tests/test_nova_cc_hooks.py b/unit_tests/test_nova_cc_hooks.py
index 65d150b..828a9dd 100644
--- a/unit_tests/test_nova_cc_hooks.py
+++ b/unit_tests/test_nova_cc_hooks.py
@@ -317,8 +317,8 @@ class NovaCCHooksTests(CharmTestCase):
317 relation_id=None), 317 relation_id=None),
318 call(authorized_keys_max_index=3, relation_id=None), 318 call(authorized_keys_max_index=3, relation_id=None),
319 call(known_hosts_max_index=3, relation_id=None)] 319 call(known_hosts_max_index=3, relation_id=None)]
320 self.assertEquals(sorted(self.relation_set.call_args_list), 320 self.assertEqual(sorted(self.relation_set.call_args_list),
321 sorted(expected_relations)) 321 sorted(expected_relations))
322 322
323 @patch.object(hooks, 'is_db_initialised') 323 @patch.object(hooks, 'is_db_initialised')
324 def test_compute_changed_nova_public_key(self, mock_is_db_initialised): 324 def test_compute_changed_nova_public_key(self, mock_is_db_initialised):
@@ -350,8 +350,8 @@ class NovaCCHooksTests(CharmTestCase):
350 relation_id=None), 350 relation_id=None),
351 call(relation_settings={'nova_authorized_keys_max_index': 3}, 351 call(relation_settings={'nova_authorized_keys_max_index': 3},
352 relation_id=None)] 352 relation_id=None)]
353 self.assertEquals(sorted(self.relation_set.call_args_list), 353 self.assertEqual(sorted(self.relation_set.call_args_list),
354 sorted(expected_relations)) 354 sorted(expected_relations))
355 355
356 @patch.object(hooks, 'canonical_url') 356 @patch.object(hooks, 'canonical_url')
357 @patch.object(utils, 'config') 357 @patch.object(utils, 'config')
@@ -690,8 +690,8 @@ class NovaCCHooksTests(CharmTestCase):
690 self.os_release.return_value = 'diablo' 690 self.os_release.return_value = 'diablo'
691 self.is_relation_made.return_value = True 691 self.is_relation_made.return_value = True
692 hooks.amqp_changed() 692 hooks.amqp_changed()
693 self.assertEquals(configs.write.call_args_list, 693 self.assertEqual(configs.write.call_args_list,
694 [call('/etc/nova/nova.conf')]) 694 [call('/etc/nova/nova.conf')])
695 cell_joined.assert_called_with(rid='nova-cell-api/0') 695 cell_joined.assert_called_with(rid='nova-cell-api/0')
696 api_joined.assert_called_with(rid='nova-api/0') 696 api_joined.assert_called_with(rid='nova-api/0')
697 quantum_joined.assert_called_with(rid='quantum-service/0', 697 quantum_joined.assert_called_with(rid='quantum-service/0',
@@ -719,8 +719,8 @@ class NovaCCHooksTests(CharmTestCase):
719 self.network_manager.return_value = 'neutron' 719 self.network_manager.return_value = 'neutron'
720 self.os_release.return_value = 'diablo' 720 self.os_release.return_value = 'diablo'
721 hooks.amqp_changed() 721 hooks.amqp_changed()
722 self.assertEquals(configs.write.call_args_list, 722 self.assertEqual(configs.write.call_args_list,
723 [call('/etc/nova/nova.conf')]) 723 [call('/etc/nova/nova.conf')])
724 cell_joined.assert_called_with(rid='nova-cell-api/0') 724 cell_joined.assert_called_with(rid='nova-cell-api/0')
725 api_joined.assert_called_with(rid='nova-api/0') 725 api_joined.assert_called_with(rid='nova-api/0')
726 quantum_joined.assert_called_with(rid='quantum-service/0', 726 quantum_joined.assert_called_with(rid='quantum-service/0',
@@ -746,7 +746,7 @@ class NovaCCHooksTests(CharmTestCase):
746 'cell_type': 'parent', 746 'cell_type': 'parent',
747 'cell_name': 'api', 747 'cell_name': 'api',
748 } 748 }
749 self.assertEquals(hooks.get_cell_type(), 'parent') 749 self.assertEqual(hooks.get_cell_type(), 'parent')
750 750
751 @patch.object(hooks, 'canonical_url') 751 @patch.object(hooks, 'canonical_url')
752 @patch.object(os, 'rename') 752 @patch.object(os, 'rename')
diff --git a/unit_tests/test_nova_cc_utils.py b/unit_tests/test_nova_cc_utils.py
index e377646..9215f77 100644
--- a/unit_tests/test_nova_cc_utils.py
+++ b/unit_tests/test_nova_cc_utils.py
@@ -255,19 +255,19 @@ class NovaCCUtilsTests(CharmTestCase):
255 def test_console_attributes_none(self): 255 def test_console_attributes_none(self):
256 self.test_config.set('console-access-protocol', 'None') 256 self.test_config.set('console-access-protocol', 'None')
257 _proto = utils.console_attributes('protocol') 257 _proto = utils.console_attributes('protocol')
258 self.assertEquals(_proto, None) 258 self.assertEqual(_proto, None)
259 self.test_config.set('console-access-protocol', 'NONE') 259 self.test_config.set('console-access-protocol', 'NONE')
260 _proto = utils.console_attributes('protocol') 260 _proto = utils.console_attributes('protocol')
261 self.assertEquals(_proto, None) 261 self.assertEqual(_proto, None)
262 self.test_config.set('console-access-protocol', 'none') 262 self.test_config.set('console-access-protocol', 'none')
263 _proto = utils.console_attributes('protocol') 263 _proto = utils.console_attributes('protocol')
264 self.assertEquals(_proto, None) 264 self.assertEqual(_proto, None)
265 self.test_config.set('console-access-protocol', None) 265 self.test_config.set('console-access-protocol', None)
266 _proto = utils.console_attributes('protocol') 266 _proto = utils.console_attributes('protocol')
267 self.assertEquals(_proto, None) 267 self.assertEqual(_proto, None)
268 self.test_config.set('console-access-protocol', "") 268 self.test_config.set('console-access-protocol', "")
269 _proto = utils.console_attributes('protocol') 269 _proto = utils.console_attributes('protocol')
270 self.assertEquals(_proto, None) 270 self.assertEqual(_proto, None)
271 271
272 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') 272 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
273 def test_resource_map_console_spice(self, subcontext): 273 def test_resource_map_console_spice(self, subcontext):
@@ -301,7 +301,7 @@ class NovaCCUtilsTests(CharmTestCase):
301 self._resource_map() 301 self._resource_map()
302 _map = utils.restart_map() 302 _map = utils.restart_map()
303 self.assertIsInstance(_map, OrderedDict) 303 self.assertIsInstance(_map, OrderedDict)
304 self.assertEquals(_map, RESTART_MAP_ICEHOUSE) 304 self.assertEqual(_map, RESTART_MAP_ICEHOUSE)
305 305
306 @patch('charmhelpers.contrib.openstack.neutron.os_release') 306 @patch('charmhelpers.contrib.openstack.neutron.os_release')
307 @patch('os.path.exists') 307 @patch('os.path.exists')
@@ -315,7 +315,7 @@ class NovaCCUtilsTests(CharmTestCase):
315 self._resource_map() 315 self._resource_map()
316 _map = utils.restart_map() 316 _map = utils.restart_map()
317 self.assertIsInstance(_map, OrderedDict) 317 self.assertIsInstance(_map, OrderedDict)
318 self.assertEquals(_map, RESTART_MAP_OCATA_ACTUAL) 318 self.assertEqual(_map, RESTART_MAP_OCATA_ACTUAL)
319 319
320 @patch('charmhelpers.contrib.openstack.neutron.os_release') 320 @patch('charmhelpers.contrib.openstack.neutron.os_release')
321 @patch('os.path.exists') 321 @patch('os.path.exists')
@@ -329,7 +329,7 @@ class NovaCCUtilsTests(CharmTestCase):
329 self._resource_map() 329 self._resource_map()
330 _map = utils.restart_map(actual_services=False) 330 _map = utils.restart_map(actual_services=False)
331 self.assertIsInstance(_map, OrderedDict) 331 self.assertIsInstance(_map, OrderedDict)
332 self.assertEquals(_map, RESTART_MAP_OCATA_BASE) 332 self.assertEqual(_map, RESTART_MAP_OCATA_BASE)
333 333
334 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') 334 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
335 @patch('os.path.exists') 335 @patch('os.path.exists')
@@ -345,7 +345,7 @@ class NovaCCUtilsTests(CharmTestCase):
345 345
346 def test_console_attributes_spice(self): 346 def test_console_attributes_spice(self):
347 _proto = utils.console_attributes('protocol', proto='spice') 347 _proto = utils.console_attributes('protocol', proto='spice')
348 self.assertEquals(_proto, 'spice') 348 self.assertEqual(_proto, 'spice')
349 349
350 def test_console_attributes_vnc(self): 350 def test_console_attributes_vnc(self):
351 self.test_config.set('console-access-protocol', 'vnc') 351 self.test_config.set('console-access-protocol', 'vnc')
@@ -355,10 +355,10 @@ class NovaCCUtilsTests(CharmTestCase):
355 _proxy_page = utils.console_attributes('proxy-page') 355 _proxy_page = utils.console_attributes('proxy-page')
356 vnc_pkgs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth'] 356 vnc_pkgs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth']
357 vnc_servs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth'] 357 vnc_servs = ['nova-novncproxy', 'nova-xvpvncproxy', 'nova-consoleauth']
358 self.assertEquals(_proto, 'vnc') 358 self.assertEqual(_proto, 'vnc')
359 self.assertEquals(_servs, vnc_servs) 359 self.assertEqual(_servs, vnc_servs)
360 self.assertEquals(_pkgs, vnc_pkgs) 360 self.assertEqual(_pkgs, vnc_pkgs)
361 self.assertEquals(_proxy_page, None) 361 self.assertEqual(_proxy_page, None)
362 362
363 def test_database_setup(self): 363 def test_database_setup(self):
364 self.relation_ids.return_value = ['shared-db:12'] 364 self.relation_ids.return_value = ['shared-db:12']
@@ -410,7 +410,7 @@ class NovaCCUtilsTests(CharmTestCase):
410 ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES)) 410 ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES))
411 # nova-placement-api is purposely dropped unless it's ocata 411 # nova-placement-api is purposely dropped unless it's ocata
412 ex.remove('nova-placement-api') 412 ex.remove('nova-placement-api')
413 self.assertEquals(ex, pkgs) 413 self.assertEqual(ex, pkgs)
414 414
415 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') 415 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
416 @patch.object(utils, 'git_install_requested') 416 @patch.object(utils, 'git_install_requested')
@@ -422,7 +422,7 @@ class NovaCCUtilsTests(CharmTestCase):
422 self.enable_memcache.return_value = False 422 self.enable_memcache.return_value = False
423 pkgs = utils.determine_packages() 423 pkgs = utils.determine_packages()
424 ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES)) 424 ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES))
425 self.assertEquals(ex, pkgs) 425 self.assertEqual(ex, pkgs)
426 426
427 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') 427 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
428 @patch.object(utils, 'git_install_requested') 428 @patch.object(utils, 'git_install_requested')
@@ -460,7 +460,7 @@ class NovaCCUtilsTests(CharmTestCase):
460 } 460 }
461 ports = utils.determine_ports() 461 ports = utils.determine_ports()
462 ex = [8773, 8774] 462 ex = [8773, 8774]
463 self.assertEquals(ex, sorted(ports)) 463 self.assertEqual(ex, sorted(ports))
464 464
465 def test_save_script_rc_base(self): 465 def test_save_script_rc_base(self):
466 self.relation_ids.return_value = [] 466 self.relation_ids.return_value = []
@@ -476,20 +476,20 @@ class NovaCCUtilsTests(CharmTestCase):
476 476
477 # icehouse -> liberty 477 # icehouse -> liberty
478 self.os_release.return_value = 'icehouse' 478 self.os_release.return_value = 'icehouse'
479 self.assertEquals( 479 self.assertEqual(
480 utils.get_step_upgrade_source('cloud:trusty-liberty'), 480 utils.get_step_upgrade_source('cloud:trusty-liberty'),
481 'cloud:trusty-kilo') 481 'cloud:trusty-kilo')
482 482
483 # juno -> liberty 483 # juno -> liberty
484 self.os_release.return_value = 'juno' 484 self.os_release.return_value = 'juno'
485 self.assertEquals( 485 self.assertEqual(
486 utils.get_step_upgrade_source('cloud:trusty-liberty'), 486 utils.get_step_upgrade_source('cloud:trusty-liberty'),
487 'cloud:trusty-kilo') 487 'cloud:trusty-kilo')
488 488
489 # kilo -> liberty 489 # kilo -> liberty
490 self.os_release.return_value = 'kilo' 490 self.os_release.return_value = 'kilo'
491 with patch_open() as (_open, _file): 491 with patch_open() as (_open, _file):
492 self.assertEquals( 492 self.assertEqual(
493 utils.get_step_upgrade_source('cloud:trusty-liberty'), 493 utils.get_step_upgrade_source('cloud:trusty-liberty'),
494 None) 494 None)
495 495
@@ -572,8 +572,8 @@ class NovaCCUtilsTests(CharmTestCase):
572 def test_ssh_directory_for_unit(self, isdir, mkdir, _open): 572 def test_ssh_directory_for_unit(self, isdir, mkdir, _open):
573 self.remote_unit.return_value = 'nova-compute/0' 573 self.remote_unit.return_value = 'nova-compute/0'
574 isdir.return_value = False 574 isdir.return_value = False
575 self.assertEquals(utils.ssh_directory_for_unit(), 575 self.assertEqual(utils.ssh_directory_for_unit(),
576 '/etc/nova/compute_ssh/nova-compute') 576 '/etc/nova/compute_ssh/nova-compute')
577 self.assertIn([ 577 self.assertIn([
578 call('/etc/nova/compute_ssh/nova-compute/authorized_keys', 'w'), 578 call('/etc/nova/compute_ssh/nova-compute/authorized_keys', 'w'),
579 call('/etc/nova/compute_ssh/nova-compute/known_hosts', 'w') 579 call('/etc/nova/compute_ssh/nova-compute/known_hosts', 'w')
@@ -582,17 +582,17 @@ class NovaCCUtilsTests(CharmTestCase):
582 @patch.object(utils, 'ssh_directory_for_unit') 582 @patch.object(utils, 'ssh_directory_for_unit')
583 def test_known_hosts(self, ssh_dir): 583 def test_known_hosts(self, ssh_dir):
584 ssh_dir.return_value = '/tmp/foo' 584 ssh_dir.return_value = '/tmp/foo'
585 self.assertEquals(utils.known_hosts(), '/tmp/foo/known_hosts') 585 self.assertEqual(utils.known_hosts(), '/tmp/foo/known_hosts')
586 ssh_dir.assert_called_with(None, None) 586 ssh_dir.assert_called_with(None, None)
587 self.assertEquals(utils.known_hosts('bar'), '/tmp/foo/known_hosts') 587 self.assertEqual(utils.known_hosts('bar'), '/tmp/foo/known_hosts')
588 ssh_dir.assert_called_with('bar', None) 588 ssh_dir.assert_called_with('bar', None)
589 589
590 @patch.object(utils, 'ssh_directory_for_unit') 590 @patch.object(utils, 'ssh_directory_for_unit')
591 def test_authorized_keys(self, ssh_dir): 591 def test_authorized_keys(self, ssh_dir):
592 ssh_dir.return_value = '/tmp/foo' 592 ssh_dir.return_value = '/tmp/foo'
593 self.assertEquals(utils.authorized_keys(), '/tmp/foo/authorized_keys') 593 self.assertEqual(utils.authorized_keys(), '/tmp/foo/authorized_keys')
594 ssh_dir.assert_called_with(None, None) 594 ssh_dir.assert_called_with(None, None)
595 self.assertEquals( 595 self.assertEqual(
596 utils.authorized_keys('bar'), 596 utils.authorized_keys('bar'),
597 '/tmp/foo/authorized_keys') 597 '/tmp/foo/authorized_keys')
598 ssh_dir.assert_called_with('bar', None) 598 ssh_dir.assert_called_with('bar', None)
@@ -647,7 +647,7 @@ class NovaCCUtilsTests(CharmTestCase):
647 def test_determine_endpoints_base(self): 647 def test_determine_endpoints_base(self):
648 self.relation_ids.return_value = [] 648 self.relation_ids.return_value = []
649 self.os_release.return_value = 'diablo' 649 self.os_release.return_value = 'diablo'
650 self.assertEquals( 650 self.assertEqual(
651 BASE_ENDPOINTS, utils.determine_endpoints('http://foohost.com', 651 BASE_ENDPOINTS, utils.determine_endpoints('http://foohost.com',
652 'http://foohost.com', 652 'http://foohost.com',
653 'http://foohost.com')) 653 'http://foohost.com'))
@@ -672,7 +672,7 @@ class NovaCCUtilsTests(CharmTestCase):
672 _known_hosts.return_value = '/foo/known_hosts' 672 _known_hosts.return_value = '/foo/known_hosts'
673 _check_output.return_value = '' 673 _check_output.return_value = ''
674 key = utils.ssh_known_host_key('test') 674 key = utils.ssh_known_host_key('test')
675 self.assertEquals(key, None) 675 self.assertEqual(key, None)
676 676
677 @patch.object(utils, 'known_hosts') 677 @patch.object(utils, 'known_hosts')
678 @patch('subprocess.check_call') 678 @patch('subprocess.check_call')
@@ -969,19 +969,19 @@ class NovaCCUtilsTests(CharmTestCase):
969 call('nova', shell='/bin/bash', system_user=True), 969 call('nova', shell='/bin/bash', system_user=True),
970 call('neutron', shell='/bin/bash', system_user=True), 970 call('neutron', shell='/bin/bash', system_user=True),
971 ] 971 ]
972 self.assertEquals(adduser.call_args_list, expected) 972 self.assertEqual(adduser.call_args_list, expected)
973 check_call.assert_called_with(['usermod', '--home', '/var/lib/nova', 973 check_call.assert_called_with(['usermod', '--home', '/var/lib/nova',
974 'nova']) 974 'nova'])
975 expected = [ 975 expected = [
976 call('nova', system_group=True), 976 call('nova', system_group=True),
977 call('neutron', system_group=True), 977 call('neutron', system_group=True),
978 ] 978 ]
979 self.assertEquals(add_group.call_args_list, expected) 979 self.assertEqual(add_group.call_args_list, expected)
980 expected = [ 980 expected = [
981 call('nova', 'nova'), 981 call('nova', 'nova'),
982 call('neutron', 'neutron'), 982 call('neutron', 'neutron'),
983 ] 983 ]
984 self.assertEquals(add_user_to_group.call_args_list, expected) 984 self.assertEqual(add_user_to_group.call_args_list, expected)
985 expected = [ 985 expected = [
986 call('/var/lib/nova', owner='nova', 986 call('/var/lib/nova', owner='nova',
987 group='nova', perms=0755, force=False), 987 group='nova', perms=0755, force=False),
@@ -1020,7 +1020,7 @@ class NovaCCUtilsTests(CharmTestCase):
1020 call('/etc/neutron/plugins/ml2', owner='nova', 1020 call('/etc/neutron/plugins/ml2', owner='nova',
1021 group='nova', perms=0755, force=False), 1021 group='nova', perms=0755, force=False),
1022 ] 1022 ]
1023 self.assertEquals(mkdir.call_args_list, expected) 1023 self.assertEqual(mkdir.call_args_list, expected)
1024 1024
1025 @patch('os.listdir') 1025 @patch('os.listdir')
1026 @patch('os.path.join') 1026 @patch('os.path.join')
@@ -1197,7 +1197,7 @@ class NovaCCUtilsTests(CharmTestCase):
1197 nova_xvpvncproxy_context, perms=0o644, 1197 nova_xvpvncproxy_context, perms=0o644,
1198 templates_dir='joined-string'), 1198 templates_dir='joined-string'),
1199 ] 1199 ]
1200 self.assertEquals(self.render.call_args_list, expected) 1200 self.assertEqual(self.render.call_args_list, expected)
1201 self.assertTrue(self.apt_update.called) 1201 self.assertTrue(self.apt_update.called)
1202 self.apt_install.assert_called_with(['novnc', 'spice-html5', 1202 self.apt_install.assert_called_with(['novnc', 'spice-html5',
1203 'websockify'], fatal=True) 1203 'websockify'], fatal=True)
@@ -1255,7 +1255,7 @@ class NovaCCUtilsTests(CharmTestCase):
1255 'joined-string', {'daemon_path': 'joined-string'}, 1255 'joined-string', {'daemon_path': 'joined-string'},
1256 perms=420), 1256 perms=420),
1257 ] 1257 ]
1258 self.assertEquals(self.render.call_args_list, expected) 1258 self.assertEqual(self.render.call_args_list, expected)
1259 1259
1260 def _test_is_api_ready(self, tgt): 1260 def _test_is_api_ready(self, tgt):
1261 fake_config = MagicMock() 1261 fake_config = MagicMock()