]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix unit tests for multiattach patch
authorWalter A. Boring IV <walter.boring@hp.com>
Wed, 11 Mar 2015 18:18:34 +0000 (11:18 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Fri, 13 Mar 2015 17:43:45 +0000 (17:43 +0000)
Part of the process of accepting the Cinder multiattach
patch was to create a follow up patch that fixes some of
the inconsistencies with order of parameters in the new
unit tests.   This patch fixes those assertX calls and
parameter ordering to be in the style of:
expected, actual

Change-Id: I4e199899afdec0497df130d02560ab58a959a0dc
Closes-Bug: #1430946

cinder/tests/test_volume.py

index 9ca4c64fc1d34ff7a533ece977b0562cecab85be..6d6aebfbd2f55afef1b424876863c9ba59ca80b4 100644 (file)
@@ -1820,7 +1820,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         ret = {}
         for item in admin_metadata:
             ret.update({item['key']: item['value']})
-        self.assertDictMatch(ret, expected)
+        self.assertDictMatch(expected, ret)
         attachment2 = self.volume.attach_volume(self.context, volume_id,
                                                 instance_uuid_2, None,
                                                 mountpoint, 'ro')
@@ -1877,7 +1877,7 @@ class VolumeTestCase(BaseVolumeTestCase):
                                                mountpoint, 'ro')
         vol = db.volume_get(context.get_admin_context(), volume_id)
         self.assertEqual('in-use', vol['status'])
-        self.assertEqual(True, vol['multiattach'])
+        self.assertTrue(vol['multiattach'])
         self.assertEqual('attached', attachment['attach_status'])
         self.assertEqual(mountpoint, attachment['mountpoint'])
         self.assertEqual(instance_uuid, attachment['instance_uuid'])
@@ -1888,7 +1888,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         ret = {}
         for item in admin_metadata:
             ret.update({item['key']: item['value']})
-        self.assertDictMatch(ret, expected)
+        self.assertDictMatch(expected, ret)
         connector = {'initiator': 'iqn.2012-07.org.fake:01'}
         conn_info = self.volume.initialize_connection(self.context,
                                                       volume_id, connector)
@@ -1947,7 +1947,7 @@ class VolumeTestCase(BaseVolumeTestCase):
                                                mountpoint, 'ro')
         vol = db.volume_get(context.get_admin_context(), volume_id)
         self.assertEqual('in-use', vol['status'])
-        self.assertEqual(False, vol['multiattach'])
+        self.assertFalse(vol['multiattach'])
         self.assertEqual('attached', attachment['attach_status'])
         self.assertEqual(mountpoint, attachment['mountpoint'])
         self.assertEqual(instance_uuid, attachment['instance_uuid'])
@@ -1958,7 +1958,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         ret = {}
         for item in admin_metadata:
             ret.update({item['key']: item['value']})
-        self.assertDictMatch(ret, expected)
+        self.assertDictMatch(expected, ret)
         connector = {'initiator': 'iqn.2012-07.org.fake:01'}
         conn_info = self.volume.initialize_connection(self.context,
                                                       volume_id, connector)
@@ -2005,7 +2005,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         self.assertEqual(mountpoint, attachment['mountpoint'])
         self.assertIsNone(attachment['instance_uuid'])
         # sanitized, conforms to RFC-952 and RFC-1123 specs.
-        self.assertEqual(attachment['attached_host'], 'fake-host')
+        self.assertEqual('fake-host', attachment['attached_host'])
         admin_metadata = vol['volume_admin_metadata']
         self.assertEqual(2, len(admin_metadata))
         expected = dict(readonly='False', attached_mode='rw')
@@ -2025,7 +2025,7 @@ class VolumeTestCase(BaseVolumeTestCase):
                           volume_id)
         self.volume.detach_volume(self.context, volume_id, attachment['id'])
         vol = db.volume_get(self.context, volume_id)
-        self.assertEqual(vol['status'], "available")
+        self.assertEqual("available", vol['status'])
 
         self.volume.delete_volume(self.context, volume_id)
         self.assertRaises(exception.VolumeNotFound,
@@ -2047,23 +2047,23 @@ class VolumeTestCase(BaseVolumeTestCase):
                                                'fake_host', mountpoint, 'rw')
         vol = db.volume_get(context.get_admin_context(), volume_id)
         self.assertEqual('in-use', vol['status'])
-        self.assertEqual(True, vol['multiattach'])
+        self.assertTrue(vol['multiattach'])
         self.assertEqual('attached', attachment['attach_status'])
         self.assertEqual(mountpoint, attachment['mountpoint'])
         self.assertIsNone(attachment['instance_uuid'])
         # sanitized, conforms to RFC-952 and RFC-1123 specs.
-        self.assertEqual(attachment['attached_host'], 'fake-host')
+        self.assertEqual('fake-host', attachment['attached_host'])
         admin_metadata = vol['volume_admin_metadata']
         self.assertEqual(2, len(admin_metadata))
         expected = dict(readonly='False', attached_mode='rw')
         ret = {}
         for item in admin_metadata:
             ret.update({item['key']: item['value']})
-        self.assertDictMatch(ret, expected)
+        self.assertDictMatch(expected, ret)
         connector = {'initiator': 'iqn.2012-07.org.fake:01'}
         conn_info = self.volume.initialize_connection(self.context,
                                                       volume_id, connector)
-        self.assertEqual(conn_info['data']['access_mode'], 'rw')
+        self.assertEqual('rw', conn_info['data']['access_mode'])
 
         mountpoint2 = "/dev/sdx"
         attachment2 = self.volume.attach_volume(self.context, volume_id, None,
@@ -2083,11 +2083,11 @@ class VolumeTestCase(BaseVolumeTestCase):
                           volume_id)
         self.volume.detach_volume(self.context, volume_id, attachment['id'])
         vol = db.volume_get(self.context, volume_id)
-        self.assertEqual(vol['status'], "in-use")
+        self.assertEqual("in-use", vol['status'])
 
         self.volume.detach_volume(self.context, volume_id, attachment2['id'])
         vol = db.volume_get(self.context, volume_id)
-        self.assertEqual(vol['status'], "available")
+        self.assertEqual("available", vol['status'])
 
         self.volume.delete_volume(self.context, volume_id)
         self.assertRaises(exception.VolumeNotFound,
@@ -2109,12 +2109,12 @@ class VolumeTestCase(BaseVolumeTestCase):
                                                'fake_host', mountpoint, 'rw')
         vol = db.volume_get(context.get_admin_context(), volume_id)
         self.assertEqual('in-use', vol['status'])
-        self.assertEqual(False, vol['multiattach'])
+        self.assertFalse(vol['multiattach'])
         self.assertEqual('attached', attachment['attach_status'])
         self.assertEqual(mountpoint, attachment['mountpoint'])
         self.assertIsNone(attachment['instance_uuid'])
         # sanitized, conforms to RFC-952 and RFC-1123 specs.
-        self.assertEqual(attachment['attached_host'], 'fake-host')
+        self.assertEqual('fake-host', attachment['attached_host'])
         admin_metadata = vol['volume_admin_metadata']
         self.assertEqual(2, len(admin_metadata))
         expected = dict(readonly='False', attached_mode='rw')
@@ -4433,7 +4433,7 @@ class CopyVolumeToImageTestCase(BaseVolumeTestCase):
                                          self.image_meta)
 
         volume = db.volume_get(self.context, self.volume_id)
-        self.assertEqual(volume['status'], 'available')
+        self.assertEqual('available', volume['status'])
 
     def test_copy_volume_to_image_exception(self):
         self.image_meta['id'] = FAKE_UUID