From: Walter A. Boring IV Date: Wed, 11 Mar 2015 18:18:34 +0000 (-0700) Subject: Fix unit tests for multiattach patch X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=125697fe094b24d788442c291d3e2a228904efd9;p=openstack-build%2Fcinder-build.git Fix unit tests for multiattach patch 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 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 9ca4c64fc..6d6aebfbd 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -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