From 0b74a1f76add93df84e987dd4b421609b5b68e2c Mon Sep 17 00:00:00 2001 From: bailinzhang Date: Fri, 17 Jun 2016 19:51:08 +0800 Subject: [PATCH] Delete reduplicate code in test_compute_mgr.py build_resources_with_network_info_obj_on_spawn_failure, test_build_resources_cleans_up_and_reraises_on_spawn_failure. the content of the cases are exactly the same. So delete one of them. Change-Id: Ic4bd314caf2cbe94a7a612637df87b7c7f552bbb --- nova/tests/unit/compute/test_compute_mgr.py | 28 --------------------- 1 file changed, 28 deletions(-) mode change 100644 => 100755 nova/tests/unit/compute/test_compute_mgr.py diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py old mode 100644 new mode 100755 index 062161142235..886e9793e7aa --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -4126,34 +4126,6 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): [mock.call(self.context, self.instance, self.requested_networks, self.security_groups)]) - @mock.patch.object(manager.ComputeManager, '_build_networks_for_instance') - @mock.patch.object(manager.ComputeManager, '_shutdown_instance') - @mock.patch.object(objects.Instance, 'save') - def test_build_resources_with_network_info_obj_on_spawn_failure(self, - mock_save, mock_shutdown, mock_build): - mock_save.return_value = self.instance - mock_build.return_value = self.network_info - - test_exception = test.TestingException() - - def fake_spawn(): - raise test_exception - - try: - with self.compute._build_resources(self.context, self.instance, - self.requested_networks, self.security_groups, - self.image, self.block_device_mapping): - fake_spawn() - except Exception as e: - self.assertEqual(test_exception, e) - - mock_save.assert_called_once_with() - mock_build.assert_called_once_with(self.context, self.instance, - self.requested_networks, self.security_groups) - mock_shutdown.assert_called_once_with(self.context, self.instance, - self.block_device_mapping, self.requested_networks, - try_deallocate_networks=False) - @mock.patch.object(manager.ComputeManager, '_build_networks_for_instance') @mock.patch.object(manager.ComputeManager, '_shutdown_instance') @mock.patch.object(objects.Instance, 'save')