diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-04-10 15:17:35 +0100 |
---|---|---|
committer | Shobhi Jain <shobhi.jain@intel.com> | 2018-05-08 11:03:45 +0000 |
commit | f6cca46f6b1aa6134a0e634a3a9e524cdbbfa729 (patch) | |
tree | 86d7a7e8106c0c0ccc8e7d49112e68e6ba96b5cb /yardstick/tests/unit/common | |
parent | 4c672aa7012a530806a2f8ff2d45a8badb7f7b21 (diff) |
Replace cinder detach volume with shade client.
Function detach volume now uses shade client.
JIRA: YARDSTICK-891
Change-Id: Ie437ccf1172cb82dc869963f0d62e31a5ab23ebb
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 9498c3c99..a1a4af2e9 100644 --- a/yardstick/tests/unit/common/test_openstack_utils.py +++ b/yardstick/tests/unit/common/test_openstack_utils.py @@ -629,3 +629,30 @@ class DeleteVolumeTestCase(unittest.TestCase): 'volume_name_or_id') mock_logger.error.assert_called_once() self.assertFalse(output) + + +class DetachVolumeTestCase(unittest.TestCase): + + @mock.patch.object(openstack_utils, 'get_server') + def test_detach_volume(self, mock_get_server): + self.mock_shade_client = mock.Mock() + mock_get_server.return_value = {'server_dict'} + self.mock_shade_client.get_volume.return_value = {'volume_dict'} + output = openstack_utils.detach_volume(self.mock_shade_client, + 'server_name_or_id', + 'volume_name_or_id') + self.assertTrue(output) + + @mock.patch.object(openstack_utils, 'get_server') + @mock.patch.object(openstack_utils, 'log') + def test_detach_volume_exception(self, mock_logger, mock_get_server): + self.mock_shade_client = mock.Mock() + mock_get_server.return_value = {'server_dict'} + self.mock_shade_client.get_volume.return_value = {'volume_dict'} + self.mock_shade_client.detach_volume.side_effect = ( + exc.OpenStackCloudException('error message')) + output = openstack_utils.detach_volume(self.mock_shade_client, + 'server_name_or_id', + 'volume_name_or_id') + mock_logger.error.assert_called_once() + self.assertFalse(output) |