From: Eric Harney Date: Mon, 4 Jan 2016 19:35:29 +0000 (-0500) Subject: Tests: Strengthen assertFalse assertions X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=40347f7bc5551730cde1ec653ba57c1e162d65c0;p=openstack-build%2Fcinder-build.git Tests: Strengthen assertFalse assertions These are all cases where we test with assertFalse, but the call returns something more specific than False which we should be checking for, such as None or []. Test for the specific expected return value rather than anything which will pass assertFalse. Change-Id: I20cf89ba23e41f5a67bbf70b2b36fb9fecdd44c4 --- diff --git a/cinder/tests/unit/targets/test_tgt_driver.py b/cinder/tests/unit/targets/test_tgt_driver.py index 587275017..f261d8393 100644 --- a/cinder/tests/unit/targets/test_tgt_driver.py +++ b/cinder/tests/unit/targets/test_tgt_driver.py @@ -121,11 +121,11 @@ class TestTgtAdmDriver(tf.TargetDriverFixture): # Test the failure case mock_execute.side_effect = putils.ProcessExecutionError - self.assertFalse(self.target._recreate_backing_lun( - self.test_vol, - '1', - self.testvol['name'], - self.testvol_path)) + self.assertIsNone( + self.target._recreate_backing_lun(self.test_vol, + '1', + self.testvol['name'], + self.testvol_path)) def test_get_iscsi_target(self): ctxt = context.get_admin_context() diff --git a/cinder/tests/unit/test_ibm_xiv_ds8k.py b/cinder/tests/unit/test_ibm_xiv_ds8k.py index 66926195b..1d652bc23 100644 --- a/cinder/tests/unit/test_ibm_xiv_ds8k.py +++ b/cinder/tests/unit/test_ibm_xiv_ds8k.py @@ -876,10 +876,10 @@ class XIVDS8KVolumeDriverTest(test.TestCase): self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, model_update['status'], "Consistency Group update failed") - self.assertFalse(added, - "added volumes list is not empty") - self.assertFalse(removed, - "removed volumes list is not empty") + self.assertIsNone(added, + "added volumes list is not empty") + self.assertIsNone(removed, + "removed volumes list is not empty") def test_update_consistencygroup_with_volumes(self): """Test update_consistencygroup when there are volumes specified.""" @@ -895,10 +895,10 @@ class XIVDS8KVolumeDriverTest(test.TestCase): self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, model_update['status'], "Consistency Group update failed") - self.assertFalse(added, - "added volumes list is not empty") - self.assertFalse(removed, - "removed volumes list is not empty") + self.assertIsNone(added, + "added volumes list is not empty") + self.assertIsNone(removed, + "removed volumes list is not empty") def test_create_consistencygroup_from_src_without_volumes(self): """Test create_consistencygroup_from_src with no volumes specified.""" diff --git a/cinder/tests/unit/test_vmware_vmdk.py b/cinder/tests/unit/test_vmware_vmdk.py index cb1006975..4cb0580a2 100644 --- a/cinder/tests/unit/test_vmware_vmdk.py +++ b/cinder/tests/unit/test_vmware_vmdk.py @@ -878,9 +878,13 @@ class VMwareVcVmdkDriverTestCase(test.TestCase): # Test with available volume. vol['status'] = 'available' vol['volume_attachment'] = None - self.assertFalse(self._driver._in_use(vol)) + self.assertIsNone(self._driver._in_use(vol)) + vol['volume_attachment'] = [] - self.assertFalse(self._driver._in_use(vol)) + ret = self._driver._in_use(vol) + # _in_use returns [] here + self.assertFalse(ret) + self.assertEqual(0, len(ret)) def _test_retype(self, ds_sel, vops, get_volume_type_extra_specs, get_volume_group_folder, genereate_uuid,