From: Sean McGinnis Date: Thu, 6 Aug 2015 22:13:36 +0000 (-0500) Subject: Correct usage of assertEqual for boolean values X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=92b65e75411e4e6a6c46281af4856d2e0b91b80d;p=openstack-build%2Fcinder-build.git Correct usage of assertEqual for boolean values 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 --- diff --git a/cinder/tests/unit/api/contrib/test_volume_unmanage.py b/cinder/tests/unit/api/contrib/test_volume_unmanage.py index f3313e4ba..cd747c2e8 100644 --- a/cinder/tests/unit/api/contrib/test_volume_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_volume_unmanage.py @@ -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) diff --git a/cinder/tests/unit/api/test_xmlutil.py b/cinder/tests/unit/api/test_xmlutil.py index 9abcd1580..1ebfa08f5 100644 --- a/cinder/tests/unit/api/test_xmlutil.py +++ b/cinder/tests/unit/api/test_xmlutil.py @@ -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 diff --git a/cinder/tests/unit/image/test_glance.py b/cinder/tests/unit/image/test_glance.py index 4df0e6676..8a265e108 100644 --- a/cinder/tests/unit/image/test_glance.py +++ b/cinder/tests/unit/image/test_glance.py @@ -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 = [] diff --git a/cinder/tests/unit/test_dothill.py b/cinder/tests/unit/test_dothill.py index e3a3cd7da..3b60d6e26 100644 --- a/cinder/tests/unit/test_dothill.py +++ b/cinder/tests/unit/test_dothill.py @@ -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): diff --git a/cinder/tests/unit/test_hplefthand.py b/cinder/tests/unit/test_hplefthand.py index c0e8450e4..1e9998ca1 100644 --- a/cinder/tests/unit/test_hplefthand.py +++ b/cinder/tests/unit/test_hplefthand.py @@ -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 = ( diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index 39fb012db..de30dd8fc 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -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, diff --git a/cinder/tests/unit/test_vzstorage.py b/cinder/tests/unit/test_vzstorage.py index ab21d241d..50332ae46 100644 --- a/cinder/tests/unit/test_vzstorage.py +++ b/cinder/tests/unit/test_vzstorage.py @@ -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): diff --git a/cinder/tests/unit/volume/drivers/test_hgst.py b/cinder/tests/unit/volume/drivers/test_hgst.py index d968ef4bb..355dc5756 100644 --- a/cinder/tests/unit/volume/drivers/test_hgst.py +++ b/cinder/tests/unit/volume/drivers/test_hgst.py @@ -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):