diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-03-26 14:56:59 +0100 |
---|---|---|
committer | Shobhi Jain <shobhi.jain@intel.com> | 2018-04-23 13:09:31 +0000 |
commit | 05f97c4e4ce1e8c7c97cda16f12215e663a13c23 (patch) | |
tree | 72698ccff36d646065037f3b671b276345b3165b /yardstick/tests/unit/common | |
parent | 069d7a13d1f8b6b465ae164e2a440c25270f7e8e (diff) |
Replace nova delete instance with shade client.
Function delete_instance now uses shade client.
JIRA: YARDSTICK-1088
Change-Id: I5772a74c6dc2d103edd410042a8eaf721d1bcc5c
Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/tests/unit/common')
-rw-r--r-- | yardstick/tests/unit/common/test_openstack_utils.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py index a7c5aa5a8..de0f5c4fa 100644 --- a/yardstick/tests/unit/common/test_openstack_utils.py +++ b/yardstick/tests/unit/common/test_openstack_utils.py @@ -366,3 +366,30 @@ class CreateInstanceTestCase(unittest.TestCase): self.mock_shade_client, 'server_name', 'image_name', 'flavor_name') mock_logger.error.assert_called_once() self.assertIsNone(output) + + +class DeleteInstanceTestCase(unittest.TestCase): + + def setUp(self): + self.mock_shade_client = mock.Mock() + + def test_delete_instance(self): + self.mock_shade_client.delete_server.return_value = True + output = openstack_utils.delete_instance(self.mock_shade_client, + 'instance_name_id') + self.assertTrue(output) + + def test_delete_instance_fail(self): + self.mock_shade_client.delete_server.return_value = False + output = openstack_utils.delete_instance(self.mock_shade_client, + 'instance_name_id') + self.assertFalse(output) + + @mock.patch.object(openstack_utils, 'log') + def test_delete_instance_exception(self, mock_logger): + self.mock_shade_client.delete_server.side_effect = ( + exc.OpenStackCloudException('error message')) + output = openstack_utils.delete_instance(self.mock_shade_client, + 'instance_name_id') + mock_logger.error.assert_called_once() + self.assertFalse(output) |