diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-05-15 08:07:47 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-05-15 08:07:47 +0000 |
commit | 29a75d1c182b6a707c36fbc48a3e4b123f390d9f (patch) | |
tree | 4871e51a8f0ae4d37725092ed2dbefa52c821f39 /yardstick/tests/unit/common | |
parent | ac190e58b127f1aa276e462292d776b5126e4944 (diff) | |
parent | f6cca46f6b1aa6134a0e634a3a9e524cdbbfa729 (diff) |
Merge "Replace cinder detach volume with shade client."
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) |