From: YuanHui Xu Date: Mon, 27 Jul 2015 04:13:49 +0000 (-0500) Subject: Add mock cases for IBM FlashSystem X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7be055d4393c75734e94efae89bc16d0d253c9db;p=openstack-build%2Fcinder-build.git Add mock cases for IBM FlashSystem This patch adds the mock method into create_volume for the IBM FlashSystem unittest code. * Case for create_volume with mocked empty return value * Case for create_volume with mocked error message for storage backend Closes-Bug: #1477820 Change-Id: Ic96551b19ccde18943279f979b952d8eea45f1f7 --- diff --git a/cinder/tests/unit/test_ibm_flashsystem.py b/cinder/tests/unit/test_ibm_flashsystem.py index 231be396a..f4c7f606a 100644 --- a/cinder/tests/unit/test_ibm_flashsystem.py +++ b/cinder/tests/unit/test_ibm_flashsystem.py @@ -846,10 +846,28 @@ class FlashSystemDriverTestCase(test.TestCase): attr_size = float(attributes['capacity']) / units.Gi self.assertEqual(float(vol['size']), attr_size) - # case 2: delete volume + # case 2: create volume with empty returning value + with mock.patch.object(FlashSystemFakeDriver, + '_ssh') as mock_ssh: + mock_ssh.return_value = ("", "") + vol1 = self._generate_vol_info(None) + self.assertRaises(exception.VolumeBackendAPIException, + self.driver.create_volume, vol1) + + # case 3: create volume with error returning value + with mock.patch.object(FlashSystemFakeDriver, + '_ssh') as mock_ssh: + mock_ssh.return_value = ("CMMVC6070E", + "An invalid or duplicated " + "parameter has been detected.") + vol2 = self._generate_vol_info(None) + self.assertRaises(exception.VolumeBackendAPIException, + self.driver.create_volume, vol2) + + # case 4: delete volume self.driver.delete_volume(vol) - # case 3: delete volume that doesn't exist (expected not fail) + # case 5: delete volume that doesn't exist (expected not fail) vol_no_exist = self._generate_vol_info(None) self.driver.delete_volume(vol_no_exist)