]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Correct usage of assertEqual for boolean values
authorSean McGinnis <sean_mcginnis@dell.com>
Thu, 6 Aug 2015 22:13:36 +0000 (17:13 -0500)
committerSean McGinnis <sean_mcginnis@dell.com>
Thu, 6 Aug 2015 22:13:36 +0000 (17:13 -0500)
There are several cases where unit tests are calling
assertEqual([True|False]) instead of the corresponding
assertTrue|assertFalse.

Pretty minor thing, but this patch corrects them to the
more correct calls.

Could add hacking check, but that seems overkill for
something like this.

Change-Id: I1de629ed9e9770157be47f4b1b0ada8388029072

cinder/tests/unit/api/contrib/test_volume_unmanage.py
cinder/tests/unit/api/test_xmlutil.py
cinder/tests/unit/image/test_glance.py
cinder/tests/unit/test_dothill.py
cinder/tests/unit/test_hplefthand.py
cinder/tests/unit/test_volume.py
cinder/tests/unit/test_vzstorage.py
cinder/tests/unit/volume/drivers/test_hgst.py

index f3313e4ba322223c72f4e6990ff5c47e6d711e81..cd747c2e8dd959a56353a41e61c1d79c1ce5dd2e 100644 (file)
@@ -144,7 +144,7 @@ class VolumeUnmanageTest(test.TestCase):
         # delete_volume is (context, status, unmanageOnly)
         self.assertEqual(1, mock_rpcapi.call_count)
         self.assertEqual(3, len(mock_rpcapi.call_args[0]))
-        self.assertEqual(True, mock_rpcapi.call_args[0][2])
+        self.assertTrue(mock_rpcapi.call_args[0][2])
 
         self.assertEqual(202, res.status_int, res)
 
index 9abcd15803dbdf800e9976f63845a25aed86d505..1ebfa08f559667f69e2e34433d342aab2a72748a 100644 (file)
@@ -312,7 +312,7 @@ class TemplateElementTest(test.TestCase):
 
         # Try setting it to a string and ensure it becomes a selector
         elem.text = 'test'
-        self.assertEqual(True, hasattr(elem.text, 'chain'))
+        self.assertTrue(hasattr(elem.text, 'chain'))
         self.assertEqual(1, len(elem.text.chain))
         self.assertEqual('test', elem.text.chain[0])
 
@@ -555,31 +555,31 @@ class TemplateTest(test.TestCase):
 
         # Construct a slave template with applicable minimum version
         slave = xmlutil.SlaveTemplate(elem, 2)
-        self.assertEqual(True, slave.apply(master))
+        self.assertTrue(slave.apply(master))
 
         # Construct a slave template with equal minimum version
         slave = xmlutil.SlaveTemplate(elem, 3)
-        self.assertEqual(True, slave.apply(master))
+        self.assertTrue(slave.apply(master))
 
         # Construct a slave template with inapplicable minimum version
         slave = xmlutil.SlaveTemplate(elem, 4)
-        self.assertEqual(False, slave.apply(master))
+        self.assertFalse(slave.apply(master))
 
         # Construct a slave template with applicable version range
         slave = xmlutil.SlaveTemplate(elem, 2, 4)
-        self.assertEqual(True, slave.apply(master))
+        self.assertTrue(slave.apply(master))
 
         # Construct a slave template with low version range
         slave = xmlutil.SlaveTemplate(elem, 1, 2)
-        self.assertEqual(False, slave.apply(master))
+        self.assertFalse(slave.apply(master))
 
         # Construct a slave template with high version range
         slave = xmlutil.SlaveTemplate(elem, 4, 5)
-        self.assertEqual(False, slave.apply(master))
+        self.assertFalse(slave.apply(master))
 
         # Construct a slave template with matching version range
         slave = xmlutil.SlaveTemplate(elem, 3, 3)
-        self.assertEqual(True, slave.apply(master))
+        self.assertTrue(slave.apply(master))
 
     def test__serialize(self):
         # Our test object to serialize
index 4df0e667688b94469021a573f29162b8ade8c5bb..8a265e1083498836dd9424cd0c58f88e8352bd44 100644 (file)
@@ -221,7 +221,7 @@ class TestGlanceImageService(test.TestCase):
 
         self.assertEqual(1, len(image_metas))
         self.assertEqual('test image', image_metas[0]['name'])
-        self.assertEqual(False, image_metas[0]['is_public'])
+        self.assertFalse(image_metas[0]['is_public'])
 
     def test_detail_marker(self):
         fixtures = []
index e3a3cd7dad3e57955a4fa4ab0d456638440b318b..3b60d6e26791553621a41951dcd62cf97cc17e51 100644 (file)
@@ -208,10 +208,10 @@ class TestDotHillClient(test.TestCase):
     def test_backend_exists(self, mock_request):
         mock_request.side_effect = [exception.DotHillRequestError,
                                     fake_xml]
-        self.assertEqual(False, self.client.backend_exists('backend_name',
-                                                           'linear'))
-        self.assertEqual(True, self.client.backend_exists('backend_name',
-                                                          'linear'))
+        self.assertFalse(self.client.backend_exists('backend_name',
+                                                    'linear'))
+        self.assertTrue(self.client.backend_exists('backend_name',
+                                                   'linear'))
 
     @mock.patch.object(dothill.DotHillClient, '_request')
     def test_backend_stats(self, mock_request):
@@ -656,8 +656,8 @@ class TestDotHillFC(test.TestCase):
         mock_retype.side_effect = [exception.Invalid, True, False]
         args = [None, None, None, None, None]
         self.assertRaises(exception.Invalid, self.driver.retype, *args)
-        self.assertEqual(True, self.driver.retype(*args))
-        self.assertEqual(False, self.driver.retype(*args))
+        self.assertTrue(self.driver.retype(*args))
+        self.assertFalse(self.driver.retype(*args))
 
     @mock.patch.object(dothill_common.DotHillCommon, 'manage_existing')
     def test_manage_existing(self, mock_manage_existing):
index c0e8450e48673d5db989714257694cee58e6f799..1e9998ca1ae092a4937f8f271b937087be3d1678 100644 (file)
@@ -2053,8 +2053,8 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
             self.assertEqual(GOODNESS_FUNCTION, stats['goodness_function'])
             self.assertEqual(FILTER_FUNCTION, stats['filter_function'])
             self.assertEqual(1, int(stats['total_volumes']))
-            self.assertEqual(True, stats['thin_provisioning_support'])
-            self.assertEqual(True, stats['thick_provisioning_support'])
+            self.assertTrue(stats['thin_provisioning_support'])
+            self.assertTrue(stats['thick_provisioning_support'])
             self.assertEqual(1, int(stats['provisioned_capacity_gb']))
 
             cap_util = (
index 39fb012db0b1bf63bc36e7c74d43fff64c4edd21..de30dd8fc49807e12ac5832b302dd4ccef94cb00 100644 (file)
@@ -2246,7 +2246,7 @@ class VolumeTestCase(BaseVolumeTestCase):
                                                 mountpoint2, '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', attachment2['attach_status'])
         self.assertEqual(mountpoint2, attachment2['mountpoint'])
         self.assertEqual(instance2_uuid, attachment2['instance_uuid'])
@@ -2315,7 +2315,7 @@ class VolumeTestCase(BaseVolumeTestCase):
                                                 mountpoint2, '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.assertIsNone(attachment2)
 
         self.assertRaises(exception.VolumeAttached,
index ab21d241d7802b562d81037f93fde7a86a741f8b..50332ae467467d079c269992712ec85a7360145d 100644 (file)
@@ -168,7 +168,7 @@ class VZStorageTestCase(test.TestCase):
         with mock.patch.object(drv, '_get_capacity_info',
                                return_value = cap_info):
             ret = drv._is_share_eligible(self._FAKE_SHARE, 50)
-            self.assertEqual(False, ret)
+            self.assertFalse(ret)
 
     def test_is_share_eligible_true(self):
         drv = self._vz_driver
@@ -176,7 +176,7 @@ class VZStorageTestCase(test.TestCase):
         with mock.patch.object(drv, '_get_capacity_info',
                                return_value = cap_info):
             ret = drv._is_share_eligible(self._FAKE_SHARE, 30)
-            self.assertEqual(True, ret)
+            self.assertTrue(ret)
 
     @mock.patch.object(image_utils, 'resize_image')
     def test_extend_volume(self, mock_resize_image):
index d968ef4bbaefcdaf36b1a9203efc15a06c241767..355dc5756d6233e8c7dfce14cee621e38b5ebfbd 100644 (file)
@@ -575,7 +575,7 @@ class HGSTTestCase(test.TestCase):
         # Check the returned provider
         expected_pid = {'provider_id': 'volume10'}
         self.assertDictMatch(expected_pid, ret)
-        self.assertEqual(True, self._request_cancel)
+        self.assertTrue(self._request_cancel)
 
     @mock.patch('socket.gethostbyname', return_value='123.123.123.123')
     def test_create_volume_blocked_and_fail(self, mock_ghn):
@@ -595,7 +595,7 @@ class HGSTTestCase(test.TestCase):
         self._return_blocked = 2  # Block & pass cancel => create failed. :(
         self.assertRaises(exception.VolumeDriverException,
                           self.driver.create_volume, volume)
-        self.assertEqual(True, self._request_cancel)
+        self.assertTrue(self._request_cancel)
 
     def test_delete_volume(self):
         """Test deleting existing volume, ensure proper name used."""
@@ -721,7 +721,7 @@ class HGSTTestCase(test.TestCase):
         self._fail_extend = True
         self.assertRaises(exception.VolumeDriverException,
                           self.driver.extend_volume, volume, 12)
-        self.assertEqual(False, self._request_cancel)
+        self.assertFalse(self._request_cancel)
 
     @mock.patch('socket.gethostbyname', return_value='123.123.123.123')
     def test_initialize_connection(self, moch_ghn):