]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add mock cases for IBM FlashSystem
authorYuanHui Xu <xuyhuish@cn.ibm.com>
Mon, 27 Jul 2015 04:13:49 +0000 (23:13 -0500)
committerYuanHui Xu <xuyhuish@cn.ibm.com>
Tue, 28 Jul 2015 01:37:56 +0000 (20:37 -0500)
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

cinder/tests/unit/test_ibm_flashsystem.py

index 231be396a82861fb1c29479ab0567955212a307e..f4c7f606a5d549de518413200aa8b88a58fb8d7f 100644 (file)
@@ -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)