Hacking Checks for assertTrue/IsNone()

This patch adds a hacking check to make sure that assertEquals isn't
comparing the result value to True or None. When developers
use assertEquals(None, return_value) the check will catch it when
pep8 runs and suggest using assertIsNone(return_value) instead.
Similar situations will occur when trying to use assertTrue(True,
return_value).

This patch also makes the necessary changes that get caught by the
new hacking check.

Change-Id: I56cc8121784eee617c09fb4e92b4ebb5877a0553
This commit is contained in:
Kendall Nelson 2015-11-17 12:39:58 -06:00
parent 2233176772
commit 635440c90c
38 changed files with 219 additions and 215 deletions

View File

@ -28,6 +28,8 @@ Cinder Specific Commandments
- [C309] Unit tests should not perform logging.
- [C310] Check for improper use of logging format arguments.
- [C311] Check for proper naming and usage in option registration.
- [C312] Check that assertIsNone(value) is used and not assertEqual(None, value).
- [C313] Check that assertTrue(value) is used and not assertEqual(True, value).
General
-------

View File

@ -61,6 +61,11 @@ log_translation_LW = re.compile(
logging_instance = re.compile(
r"(.)*LOG\.(warning|info|debug|error|exception)\(")
assert_None = re.compile(
r".*assertEqual\(None, .*\)")
assert_True = re.compile(
r".*assertEqual\(True, .*\)")
class BaseASTChecker(ast.NodeVisitor):
"""Provides a simple framework for writing AST-based checks.
@ -474,6 +479,20 @@ def no_test_log(logical_line, filename, noqa):
yield (0, msg)
def validate_assertIsNone(logical_line):
if re.match(assert_None, logical_line):
msg = ("C312: Unit tests should use assertIsNone(value) instead"
" of using assertEqual(None, value).")
yield(0, msg)
def validate_assertTrue(logical_line):
if re.match(assert_True, logical_line):
msg = ("C313: Unit tests should use assertTrue(value) instead"
" of using assertEqual(True, value).")
yield(0, msg)
def factory(register):
register(no_vi_headers)
register(no_translate_debug_logs)
@ -494,3 +513,5 @@ def factory(register):
register(no_log_warn)
register(dict_constructor_with_list_copy)
register(no_test_log)
register(validate_assertIsNone)
register(validate_assertTrue)

View File

@ -163,7 +163,7 @@ class AdminActionsTest(test.TestCase):
self.assertEqual(400, resp.status_int)
volume = db.volume_get(ctx, volume['id'])
self.assertEqual(None, volume['migration_status'])
self.assertIsNone(volume['migration_status'])
def test_reset_migration_status(self):
ctx = context.RequestContext('admin', 'fake', True)

View File

@ -925,34 +925,28 @@ class BackupsAPITestCase(test.TestCase):
volume = self.volume_api.get(context.get_admin_context(), volume_id)
# test empty service
self.assertEqual(False,
self.backup_api._is_backup_service_enabled(volume,
test_host))
self.assertEqual(False, self.backup_api._is_backup_service_enabled(
volume, test_host))
# test host not match service
self.assertEqual(False,
self.backup_api._is_backup_service_enabled(volume,
test_host))
self.assertEqual(False, self.backup_api._is_backup_service_enabled(
volume, test_host))
# test az not match service
self.assertEqual(False,
self.backup_api._is_backup_service_enabled(volume,
test_host))
self.assertEqual(False, self.backup_api._is_backup_service_enabled(
volume, test_host))
# test disabled service
self.assertEqual(False,
self.backup_api._is_backup_service_enabled(volume,
test_host))
self.assertEqual(False, self.backup_api._is_backup_service_enabled(
volume, test_host))
# test dead service
self.assertEqual(False,
self.backup_api._is_backup_service_enabled(volume,
test_host))
self.assertEqual(False, self.backup_api._is_backup_service_enabled(
volume, test_host))
# test multi services and the last service matches
self.assertEqual(True,
self.backup_api._is_backup_service_enabled(volume,
test_host))
self.assertTrue(self.backup_api._is_backup_service_enabled(volume,
test_host))
def test_delete_backup_available(self):
backup_id = self._create_backup(status='available')

View File

@ -750,7 +750,7 @@ class VolumeApiTest(test.TestCase):
req = fakes.HTTPRequest.blank('/v1/volumes/1')
res_dict = self.controller.show(req, 1)
self.assertEqual(True, res_dict['volume']['encrypted'])
self.assertTrue(res_dict['volume']['encrypted'])
def test_volume_show_with_unencrypted_volume(self):
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_api_get)

View File

@ -1078,7 +1078,7 @@ class VolumeApiTest(test.TestCase):
filters=None,
viewable_admin_meta=False,
offset=0):
self.assertEqual(True, filters['no_migration_targets'])
self.assertTrue(filters['no_migration_targets'])
self.assertFalse('all_tenants' in filters)
return [stubs.stub_volume(1, display_name='vol1')]
@ -1242,7 +1242,7 @@ class VolumeApiTest(test.TestCase):
req = fakes.HTTPRequest.blank('/v2/volumes/1')
res_dict = self.controller.show(req, 1)
self.assertEqual(True, res_dict['volume']['encrypted'])
self.assertTrue(res_dict['volume']['encrypted'])
def test_volume_show_with_unencrypted_volume(self):
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_api_get)

View File

@ -153,8 +153,7 @@ class BrickLvmTestCase(test.TestCase):
return (data, "")
def test_create_lv_snapshot(self):
self.assertEqual(None,
self.vg.create_lv_snapshot('snapshot-1', 'fake-1'))
self.assertIsNone(self.vg.create_lv_snapshot('snapshot-1', 'fake-1'))
self.mox.StubOutWithMock(self.vg, 'get_volume')
self.vg.get_volume('fake-non-existent').AndReturn(None)
@ -167,7 +166,7 @@ class BrickLvmTestCase(test.TestCase):
self.fail("Exception not raised")
def test_vg_exists(self):
self.assertEqual(True, self.vg._vg_exists())
self.assertTrue(self.vg._vg_exists())
def test_get_vg_uuid(self):
self.assertEqual('kVxztV-dKpG-Rz7E-xtKY-jeju-QsYU-SLG6Z1',
@ -184,7 +183,7 @@ class BrickLvmTestCase(test.TestCase):
self.assertEqual('fake-1', self.vg.get_volume('fake-1')['name'])
def test_get_volume_none(self):
self.assertEqual(None, self.vg.get_volume('fake-unknown'))
self.assertIsNone(self.vg.get_volume('fake-unknown'))
def test_get_lv_info_notfound(self):
# lv-nothere will raise lvm < 2.102.112 exception

View File

@ -554,7 +554,7 @@ class TestGlanceImageService(test.TestCase):
self.flags(allowed_direct_url_schemes=['file'])
self.flags(glance_api_version=2)
self.service.download(self.context, image_id, writer)
self.assertEqual(None, mock_copyfileobj.call_args)
self.assertIsNone(mock_copyfileobj.call_args)
def test_glance_client_image_id(self):
fixture = self._make_fixture(name='test image')

View File

@ -414,7 +414,7 @@ class HostStateTestCase(test.TestCase):
fake_host.update_from_volume_capability(volume_capability)
# Backend level stats remain uninitialized
self.assertEqual(0, fake_host.total_capacity_gb)
self.assertEqual(None, fake_host.free_capacity_gb)
self.assertIsNone(fake_host.free_capacity_gb)
# Pool stats has been updated
self.assertEqual(1024, fake_host.pools['_pool0'].total_capacity_gb)
self.assertEqual(512, fake_host.pools['_pool0'].free_capacity_gb)
@ -481,7 +481,7 @@ class HostStateTestCase(test.TestCase):
# Backend level stats remain uninitialized
self.assertEqual(0, fake_host.total_capacity_gb)
self.assertEqual(None, fake_host.free_capacity_gb)
self.assertIsNone(fake_host.free_capacity_gb)
# Pool stats has been updated
self.assertEqual(2, len(fake_host.pools))
@ -540,7 +540,7 @@ class HostStateTestCase(test.TestCase):
fake_host.update_from_volume_capability(volume_capability)
# Backend level stats remain uninitialized
self.assertEqual(0, fake_host.total_capacity_gb)
self.assertEqual(None, fake_host.free_capacity_gb)
self.assertIsNone(fake_host.free_capacity_gb)
# Pool stats has been updated
self.assertEqual(
'infinite',
@ -561,7 +561,7 @@ class HostStateTestCase(test.TestCase):
fake_host.update_from_volume_capability(volume_capability)
# Backend level stats remain uninitialized
self.assertEqual(0, fake_host.total_capacity_gb)
self.assertEqual(None, fake_host.free_capacity_gb)
self.assertIsNone(fake_host.free_capacity_gb)
# Pool stats has been updated
self.assertEqual(
'infinite',
@ -577,7 +577,7 @@ class HostStateTestCase(test.TestCase):
fake_host.update_from_volume_capability(vol_cap)
self.assertEqual(0, fake_host.total_capacity_gb)
self.assertEqual(None, fake_host.free_capacity_gb)
self.assertIsNone(fake_host.free_capacity_gb)
# Pool stats has been updated
self.assertEqual(0,
fake_host.pools['_pool0'].total_capacity_gb)

View File

@ -105,8 +105,8 @@ class TestBaseISCSITargetDriver(tf.TargetDriverFixture):
mock_get_target.side_effect = exception.NotFound
ctxt = context.get_admin_context()
self.assertEqual(None, self.target.remove_export(ctxt,
self.testvol))
self.assertIsNone(self.target.remove_export(ctxt,
self.testvol))
def test_remove_export_show_error(self):
@ -119,8 +119,8 @@ class TestBaseISCSITargetDriver(tf.TargetDriverFixture):
iscsi_target, lun = mock_get_target.return_value
mshow.side_effect = Exception
ctxt = context.get_admin_context()
self.assertEqual(None, self.target.remove_export(ctxt,
self.testvol))
self.assertIsNone(self.target.remove_export(ctxt,
self.testvol))
def test_initialize_connection(self):
expected = {'driver_volume_type': 'iscsi',

View File

@ -242,13 +242,11 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
mock_exec.side_effect = _fake_execute
with mock.patch.object(self.target, '_get_target', return_value=False):
self.assertEqual(
None,
self.target.remove_iscsi_target(
1,
0,
self.VOLUME_ID,
self.VOLUME_NAME))
self.assertIsNone(self.target.remove_iscsi_target(
1,
0,
self.VOLUME_ID,
self.VOLUME_NAME))
mock_exec.side_effect = _fake_execute_wrong_message
self.assertRaises(exception.ISCSITargetRemoveFailed,
@ -284,13 +282,11 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
mock_exec.side_effect = _fake_execute
with mock.patch.object(self.target, '_get_target', return_value=False):
self.assertEqual(
None,
self.target.remove_iscsi_target(
1,
0,
self.VOLUME_ID,
self.VOLUME_NAME))
self.assertIsNone(self.target.remove_iscsi_target(
1,
0,
self.VOLUME_ID,
self.VOLUME_NAME))
mock_exec.side_effect = _fake_execute_wrong_message
self.assertRaises(exception.ISCSITargetRemoveFailed,
@ -327,12 +323,11 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
# Test the failure case: path does not exist
mock_path_exists.return_value = None
self.assertEqual(None,
self.target.remove_iscsi_target(
0,
1,
self.testvol['id'],
self.testvol['name']))
self.assertIsNone(self.target.remove_iscsi_target(
0,
1,
self.testvol['id'],
self.testvol['name']))
# Test the normal case
mock_path_exists.return_value = True

View File

@ -196,9 +196,8 @@ class TestURLMap(test.TestCase):
self.assertEqual('value', wrap(self.input_environ, start_response))
def test_content_type_strategy_without_version(self):
self.assertEqual(None,
self.urlmap._content_type_strategy('host', 20,
self.environ))
self.assertIsNone(self.urlmap._content_type_strategy('host', 20,
self.environ))
def test_content_type_strategy_with_version(self):
environ = {'HTTP_ACCEPT': "application/vnd.openstack.melange+xml;"

View File

@ -712,7 +712,7 @@ class BackupTestCase(BaseBackupTest):
ctxt_read_deleted = context.get_admin_context('yes')
backup = db.backup_get(ctxt_read_deleted, backup.id)
self.assertEqual(True, backup.deleted)
self.assertTrue(backup.deleted)
self.assertGreaterEqual(timeutils.utcnow(), backup.deleted_at)
self.assertEqual('deleted', backup.status)

View File

@ -1111,9 +1111,7 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
'CustomerA', self.driver.configuration.cb_account_name)
# assert the result
self.assertEqual(
None,
provider_details['provider_auth'])
self.assertIsNone(provider_details['provider_auth'])
self.assertThat(
provider_details['provider_location'],
matchers.Contains('172.16.50.35:3260'))
@ -1343,9 +1341,7 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
self.driver.create_volume_from_snapshot(cloned_volume, snapshot))
# assert the result
self.assertEqual(
None,
provider_details['provider_auth'])
self.assertIsNone(provider_details['provider_auth'])
self.assertEqual(
'20.10.22.56:3260 '
'iqn.2014-06.acc1.openstacktsm:acc1DS1Snap1clone1 0',
@ -1413,8 +1409,7 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
model_update = self.driver.create_export({}, {}, {})
# assert the result
self.assertEqual(None,
model_update['provider_auth'])
self.assertIsNone(model_update['provider_auth'])
@mock.patch.object(cloudbyte.CloudByteISCSIDriver,
'_api_request_for_cloudbyte')
@ -1450,8 +1445,7 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
model_update = self.driver.create_export({}, {}, {})
# assert the result
self.assertEqual(None,
model_update['provider_auth'])
self.assertIsNone(model_update['provider_auth'])
@mock.patch.object(cloudbyte.CloudByteISCSIDriver,
'_api_request_for_cloudbyte')

View File

@ -25,13 +25,13 @@ class ContextTestCase(test.TestCase):
ctxt = context.RequestContext('111',
'222',
roles=['admin', 'weasel'])
self.assertEqual(True, ctxt.is_admin)
self.assertTrue(ctxt.is_admin)
def test_request_context_sets_is_admin_upcase(self):
ctxt = context.RequestContext('111',
'222',
roles=['Admin', 'weasel'])
self.assertEqual(True, ctxt.is_admin)
self.assertTrue(ctxt.is_admin)
def test_request_context_read_deleted(self):
ctxt = context.RequestContext('111',

View File

@ -2236,7 +2236,7 @@ class DellSCSanAPITestCase(test.TestCase):
mock_init):
# Test calling find_volume with no name or instanceid
res = self.scapi.find_volume(None)
self.assertEqual(None, res, 'Expected None')
self.assertIsNone(res, 'Expected None')
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'_get_volume_list')
@ -2248,7 +2248,7 @@ class DellSCSanAPITestCase(test.TestCase):
# Test calling find_volume with result of no volume found
mock_get_volume_list.side_effect = [[], []]
res = self.scapi.find_volume(self.volume_name)
self.assertEqual(None, res, 'None expected')
self.assertIsNone(res, 'None expected')
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'_get_volume_list',
@ -2448,7 +2448,7 @@ class DellSCSanAPITestCase(test.TestCase):
mock_open_connection,
mock_init):
res = self.scapi._find_serveros('Red Hat Linux 6.x')
self.assertEqual(None, res, 'None expected')
self.assertIsNone(res, 'None expected')
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'_add_hba',
@ -3018,7 +3018,7 @@ class DellSCSanAPITestCase(test.TestCase):
self.SCSERVER)
self.assertTrue(mock_find_fc_initiators.called)
self.assertTrue(mock_find_mappings.called)
self.assertEqual(None, lun, 'Incorrect LUN')
self.assertIsNone(lun, 'Incorrect LUN')
self.assertEqual([], wwns, 'WWNs is not empty')
self.assertEqual({}, itmap, 'WWN mapping not empty')
@ -3044,7 +3044,7 @@ class DellSCSanAPITestCase(test.TestCase):
self.assertTrue(mock_find_fc_initiators.called)
self.assertTrue(mock_find_mappings.called)
self.assertTrue(mock_find_controller_port.called)
self.assertEqual(None, lun, 'Incorrect LUN')
self.assertIsNone(lun, 'Incorrect LUN')
self.assertEqual([], wwns, 'WWNs is not empty')
self.assertEqual({}, itmap, 'WWN mapping not empty')
@ -3072,7 +3072,7 @@ class DellSCSanAPITestCase(test.TestCase):
self.assertTrue(mock_find_mappings.called)
self.assertTrue(mock_find_controller_port.called)
self.assertEqual(None, lun, 'Incorrect LUN')
self.assertIsNone(lun, 'Incorrect LUN')
self.assertEqual([], wwns, 'WWNs is not empty')
self.assertEqual({}, itmap, 'WWN mapping not empty')
@ -3099,7 +3099,7 @@ class DellSCSanAPITestCase(test.TestCase):
self.assertTrue(mock_find_mappings.called)
self.assertTrue(mock_find_controller_port.called)
self.assertEqual(None, lun, 'Incorrect LUN')
self.assertIsNone(lun, 'Incorrect LUN')
self.assertEqual([], wwns, 'WWNs is not empty')
self.assertEqual({}, itmap, 'WWN mapping not empty')
@ -3162,7 +3162,7 @@ class DellSCSanAPITestCase(test.TestCase):
# Test case of where get of ScVolume MappingList fails
res = self.scapi._find_active_controller(self.VOLUME)
self.assertTrue(mock_get.called)
self.assertEqual(None, res, 'Expected None')
self.assertIsNone(res, 'Expected None')
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'_find_active_controller',
@ -3995,7 +3995,7 @@ class DellSCSanAPITestCase(test.TestCase):
mock_init):
res = self.scapi._find_controller_port_iscsi_config('guid')
self.assertTrue(mock_get.called)
self.assertEqual(None, res)
self.assertIsNone(res)
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'_get_json',
@ -4624,7 +4624,7 @@ class DellSCSanAPITestCase(test.TestCase):
res = self.scapi.find_replay_profile('guid')
self.assertTrue(mock_post.called)
self.assertTrue(mock_get_json.called)
self.assertEqual(None, res, 'Unexpected return')
self.assertIsNone(res, 'Unexpected return')
@mock.patch.object(dell_storagecenter_api.HttpClient,
'post',
@ -4636,7 +4636,7 @@ class DellSCSanAPITestCase(test.TestCase):
mock_init):
res = self.scapi.find_replay_profile('guid')
self.assertTrue(mock_post.called)
self.assertEqual(None, res, 'Unexpected return')
self.assertIsNone(res, 'Unexpected return')
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'find_replay_profile',
@ -4687,7 +4687,7 @@ class DellSCSanAPITestCase(test.TestCase):
res = self.scapi.create_replay_profile('guid')
self.assertTrue(mock_find_replay_profile.called)
self.assertTrue(mock_post.called)
self.assertEqual(None, res, 'Unexpected return')
self.assertIsNone(res, 'Unexpected return')
@mock.patch.object(dell_storagecenter_api.HttpClient,
'delete',
@ -4757,7 +4757,7 @@ class DellSCSanAPITestCase(test.TestCase):
res = self.scapi._get_volume_configuration({})
self.assertTrue(mock_get_id.called)
self.assertTrue(mock_get.called)
self.assertEqual(None, res, 'Unexpected result')
self.assertIsNone(res, 'Unexpected result')
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
'_get_volume_configuration',

View File

@ -199,7 +199,7 @@ class TestDotHillClient(test.TestCase):
not_ok_tree = etree.XML(response_not_ok)
invalid_tree = etree.XML(invalid_xml)
ret = self.client._assert_response_ok(ok_tree)
self.assertEqual(None, ret)
self.assertIsNone(ret)
self.assertRaises(exception.DotHillRequestError,
self.client._assert_response_ok,
not_ok_tree)
@ -312,7 +312,7 @@ class TestFCDotHillCommon(test.TestCase):
mock_serial_number.return_value = "xxxxx"
self.assertRaises(exception.DotHillInvalidBackend,
self.common.do_setup, None)
self.assertEqual(None, self.common.do_setup(None))
self.assertIsNone(self.common.do_setup(None))
mock_backend_exists.assert_called_with(self.common.backend_name,
self.common.backend_type)
mock_owner_info.assert_called_with(self.common.backend_name,
@ -331,7 +331,7 @@ class TestFCDotHillCommon(test.TestCase):
options = FakeOptions({'opt1': 'val1', 'opt2': 'val2'})
required_flags = ['opt1', 'opt2']
ret = self.common.check_flags(options, required_flags)
self.assertEqual(None, ret)
self.assertIsNone(ret)
options = FakeOptions({'opt1': 'val1', 'opt2': 'val2'})
required_flags = ['opt1', 'opt2', 'opt3']
@ -356,7 +356,7 @@ class TestFCDotHillCommon(test.TestCase):
self.common.backend_type)
ret = self.common._update_volume_stats()
self.assertEqual(None, ret)
self.assertIsNone(ret)
self.assertEqual({'driver_version': self.common.VERSION,
'pools': [{'QoS_support': False,
'free_capacity_gb': 90,
@ -375,7 +375,7 @@ class TestFCDotHillCommon(test.TestCase):
self.assertRaises(exception.Invalid, self.common.create_volume,
test_volume)
ret = self.common.create_volume(test_volume)
self.assertEqual(None, ret)
self.assertIsNone(ret)
mock_create.assert_called_with(encoded_volid,
"%sGB" % test_volume['size'],
self.common.backend_name,
@ -387,10 +387,10 @@ class TestFCDotHillCommon(test.TestCase):
'The volume was not found on this system.')
mock_delete.side_effect = [not_found_e, exception.DotHillRequestError,
None]
self.assertEqual(None, self.common.delete_volume(test_volume))
self.assertIsNone(self.common.delete_volume(test_volume))
self.assertRaises(exception.Invalid, self.common.delete_volume,
test_volume)
self.assertEqual(None, self.common.delete_volume(test_volume))
self.assertIsNone(self.common.delete_volume(test_volume))
mock_delete.assert_called_with(encoded_volid)
@mock.patch.object(dothill.DotHillClient, 'copy_volume')
@ -410,7 +410,7 @@ class TestFCDotHillCommon(test.TestCase):
dest_volume, detached_volume)
ret = self.common.create_cloned_volume(dest_volume, detached_volume)
self.assertEqual(None, ret)
self.assertIsNone(ret)
mock_copy.assert_called_with(encoded_volid,
'vqqqqqqqqqqqqqqqqqqq',
@ -433,7 +433,7 @@ class TestFCDotHillCommon(test.TestCase):
dest_volume, test_snap)
ret = self.common.create_volume_from_snapshot(dest_volume, test_snap)
self.assertEqual(None, ret)
self.assertIsNone(ret)
mock_copy.assert_called_with('sqqqqqqqqqqqqqqqqqqq',
'vqqqqqqqqqqqqqqqqqqq',
self.common.backend_name,
@ -446,7 +446,7 @@ class TestFCDotHillCommon(test.TestCase):
self.assertRaises(exception.Invalid, self.common.extend_volume,
test_volume, 20)
ret = self.common.extend_volume(test_volume, 20)
self.assertEqual(None, ret)
self.assertIsNone(ret)
mock_extend.assert_called_with(encoded_volid, '10GB')
@mock.patch.object(dothill.DotHillClient, 'create_snapshot')
@ -456,7 +456,7 @@ class TestFCDotHillCommon(test.TestCase):
self.assertRaises(exception.Invalid, self.common.create_snapshot,
test_snap)
ret = self.common.create_snapshot(test_snap)
self.assertEqual(None, ret)
self.assertIsNone(ret)
mock_create.assert_called_with(encoded_volid, 'sqqqqqqqqqqqqqqqqqqq')
@mock.patch.object(dothill.DotHillClient, 'delete_snapshot')
@ -466,10 +466,10 @@ class TestFCDotHillCommon(test.TestCase):
mock_delete.side_effect = [not_found_e, exception.DotHillRequestError,
None]
self.assertEqual(None, self.common.delete_snapshot(test_snap))
self.assertIsNone(self.common.delete_snapshot(test_snap))
self.assertRaises(exception.Invalid, self.common.delete_snapshot,
test_snap)
self.assertEqual(None, self.common.delete_snapshot(test_snap))
self.assertIsNone(self.common.delete_snapshot(test_snap))
mock_delete.assert_called_with('sqqqqqqqqqqqqqqqqqqq')
@mock.patch.object(dothill.DotHillClient, 'map_volume')
@ -492,7 +492,7 @@ class TestFCDotHillCommon(test.TestCase):
test_volume, connector, self.connector_element)
ret = self.common.unmap_volume(test_volume, connector,
self.connector_element)
self.assertEqual(None, ret)
self.assertIsNone(ret)
mock_unmap.assert_called_with(encoded_volid, connector,
self.connector_element)
@ -517,7 +517,7 @@ class TestFCDotHillCommon(test.TestCase):
self.assertRaises(exception.Invalid, self.common.manage_existing,
test_volume, existing_ref)
ret = self.common.manage_existing(test_volume, existing_ref)
self.assertEqual(None, ret)
self.assertIsNone(ret)
@mock.patch.object(dothill.DotHillClient, 'get_volume_size')
def test_manage_existing_get_size(self, mock_volume):
@ -733,4 +733,4 @@ class TestDotHillISCSI(TestDotHillFC):
mock_unmap.assert_called_with(test_volume, connector, 'initiator')
ret = self.driver.terminate_connection(test_volume, connector)
self.assertEqual(None, ret)
self.assertIsNone(ret)

View File

@ -2071,9 +2071,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
self.assertIsNone(rc)
self.driver.utils._is_job_finished.assert_called_once_with(
conn, myjob)
self.assertEqual(
True,
self.driver.utils._is_job_finished.return_value)
self.assertTrue(self.driver.utils._is_job_finished.return_value)
self.driver.utils._is_job_finished.reset_mock()
# Save the original state and restore it after this test
@ -2096,9 +2094,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
self.assertIsNone(rc)
self.driver.utils._is_sync_complete.assert_called_once_with(
conn, mysync)
self.assertEqual(
True,
self.driver.utils._is_sync_complete.return_value)
self.assertTrue(self.driver.utils._is_sync_complete.return_value)
self.driver.utils._is_sync_complete.reset_mock()
# Save the original state and restore it after this test
@ -2130,9 +2126,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
self.assertIsNone(rc)
self.driver.utils._is_sync_complete.assert_called_once_with(
conn, mysync)
self.assertEqual(
True,
self.driver.utils._is_sync_complete.return_value)
self.assertTrue(self.driver.utils._is_sync_complete.return_value)
self.assertEqual(40,
self.driver.utils._get_max_job_retries(extraSpecs))
self.assertEqual(5,
@ -6733,7 +6727,7 @@ class EMCV2MultiPoolDriverMultipleEcomsTestCase(test.TestCase):
self.assertEqual(self.data.poolname, poolRec['PoolName'])
self.assertEqual('user', poolRec['EcomUserName'])
self.assertEqual('pass', poolRec['EcomPassword'])
self.assertEqual(None, poolRec['FastPolicy'])
self.assertIsNone(poolRec['FastPolicy'])
self.assertFalse(poolRec['EcomUseSSL'])
def test_array_info_multi_ecom_fast(self):

View File

@ -392,22 +392,22 @@ class GPFSDriverTestCase(test.TestCase):
@mock.patch('cinder.utils.execute')
def test_can_migrate_locally(self, mock_exec):
host = {'host': 'foo', 'capabilities': ''}
self.assertEqual(None, self.driver._can_migrate_locally(host))
self.assertIsNone(self.driver._can_migrate_locally(host))
loc = 'GPFSDriver:%s' % self.driver._cluster_id
cap = {'location_info': loc}
host = {'host': 'foo', 'capabilities': cap}
self.assertEqual(None, self.driver._can_migrate_locally(host))
self.assertIsNone(self.driver._can_migrate_locally(host))
loc = 'GPFSDriver_:%s:testpath' % self.driver._cluster_id
cap = {'location_info': loc}
host = {'host': 'foo', 'capabilities': cap}
self.assertEqual(None, self.driver._can_migrate_locally(host))
self.assertIsNone(self.driver._can_migrate_locally(host))
loc = 'GPFSDriver:%s:testpath' % (self.driver._cluster_id + '_')
cap = {'location_info': loc}
host = {'host': 'foo', 'capabilities': cap}
self.assertEqual(None, self.driver._can_migrate_locally(host))
self.assertIsNone(self.driver._can_migrate_locally(host))
loc = 'GPFSDriver:%s:testpath' % self.driver._cluster_id
cap = {'location_info': loc}
@ -1112,13 +1112,13 @@ class GPFSDriverTestCase(test.TestCase):
check_exit_code=False)
def test_ensure_export(self):
self.assertEqual(None, self.driver.ensure_export('', ''))
self.assertIsNone(self.driver.ensure_export('', ''))
def test_create_export(self):
self.assertEqual(None, self.driver.create_export('', '', {}))
self.assertIsNone(self.driver.create_export('', '', {}))
def test_remove_export(self):
self.assertEqual(None, self.driver.remove_export('', ''))
self.assertIsNone(self.driver.remove_export('', ''))
@mock.patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver.local_path')
def test_initialize_connection(self, mock_local_path):
@ -1130,7 +1130,7 @@ class GPFSDriverTestCase(test.TestCase):
self.assertEqual('gpfs', data['driver_volume_type'])
def test_terminate_connection(self):
self.assertEqual(None, self.driver.terminate_connection('', ''))
self.assertIsNone(self.driver.terminate_connection('', ''))
def test_get_volume_stats(self):
fake_avail = 80 * units.Gi

View File

@ -62,7 +62,7 @@ class HackingTestCase(test.TestCase):
'Line 6\n', 'Line 7\n', 'Line 8\n', 'Line 9\n', 'Line 10\n',
'Line 11\n']
self.assertEqual(None, checks.no_vi_headers(
self.assertIsNone(checks.no_vi_headers(
"Test string foo", 1, lines))
self.assertEqual(2, len(list(checks.no_vi_headers(
"# vim: et tabstop=4 shiftwidth=4 softtabstop=4",
@ -70,11 +70,11 @@ class HackingTestCase(test.TestCase):
self.assertEqual(2, len(list(checks.no_vi_headers(
"# vim: et tabstop=4 shiftwidth=4 softtabstop=4",
8, lines))))
self.assertEqual(None, checks.no_vi_headers(
self.assertIsNone(checks.no_vi_headers(
"Test end string for vi",
9, lines))
# vim header outside of boundary (first/last 5 lines)
self.assertEqual(None, checks.no_vi_headers(
self.assertIsNone(checks.no_vi_headers(
"# vim: et tabstop=4 shiftwidth=4 softtabstop=4",
6, lines))
@ -414,6 +414,20 @@ class HackingTestCase(test.TestCase):
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
" self._render_dict(xml, data_el, data.__dict__)"))))
def test_validate_assertIsNone(self):
test_value = None
self.assertEqual(0, len(list(checks.validate_assertIsNone(
"assertIsNone(None)"))))
self.assertEqual(1, len(list(checks.validate_assertIsNone(
"assertEqual(None, %s)" % test_value))))
def test_validate_assertTrue(self):
test_value = True
self.assertEqual(0, len(list(checks.validate_assertTrue(
"assertTrue(True)"))))
self.assertEqual(1, len(list(checks.validate_assertTrue(
"assertEqual(True, %s)" % test_value))))
@ddt.unpack
@ddt.data(
(1, 'LOG.info', "cinder/tests/unit/fake.py", False),

View File

@ -285,7 +285,7 @@ class HDSNFSDriverTest(test.TestCase):
m_volume_not_present.return_value = True
self.driver.delete_snapshot(svol)
self.assertEqual(None, svol['provider_location'])
self.assertIsNone(svol['provider_location'])
@mock.patch.object(nfs.HDSNFSDriver, '_get_service')
@mock.patch.object(nfs.HDSNFSDriver, '_id_to_vol', side_effect=id_to_vol)

View File

@ -693,7 +693,7 @@ class HPXPFCDriverTest(test.TestCase):
volume = fake_volume.fake_db_volume(**self._VOLUME)
rc = self.driver.manage_existing(volume, existing_ref)
self.assertEqual(None, rc['provider_location'])
self.assertIsNone(rc['provider_location'])
def test_manage_existing_get_size(self):
"""Test manage_existing_get_size."""

View File

@ -707,7 +707,7 @@ class HPE3PARBaseDriver(object):
self.standard_login +
expected +
self.standard_logout)
self.assertEqual(None, return_model)
self.assertIsNone(return_model)
@mock.patch.object(volume_types, 'get_volume_type')
def test_unsupported_dedup_volume_type(self, _mock_volume_types):
@ -863,7 +863,7 @@ class HPE3PARBaseDriver(object):
self.standard_login +
expected +
self.standard_logout)
self.assertEqual(None, return_model)
self.assertIsNone(return_model)
@mock.patch.object(volume_types, 'get_volume_type')
def test_create_volume_dedup(self, _mock_volume_types):
@ -907,7 +907,7 @@ class HPE3PARBaseDriver(object):
self.standard_login +
expected +
self.standard_logout)
self.assertEqual(None, return_model)
self.assertIsNone(return_model)
@mock.patch.object(volume_types, 'get_volume_type')
def test_create_volume_flash_cache(self, _mock_volume_types):
@ -970,7 +970,7 @@ class HPE3PARBaseDriver(object):
self.standard_login +
expected +
self.standard_logout)
self.assertEqual(None, return_model)
self.assertIsNone(return_model)
@mock.patch.object(volume_types, 'get_volume_type')
def test_unsupported_flash_cache_volume(self, _mock_volume_types):
@ -1408,7 +1408,7 @@ class HPE3PARBaseDriver(object):
volume['host'] = volume_host
volume['source_volid'] = HPE3PARBaseDriver.CLONE_ID
model_update = self.driver.create_cloned_volume(volume, src_vref)
self.assertEqual(None, model_update)
self.assertIsNone(model_update)
expected = [
mock.call.getCPG(expected_cpg),
@ -1969,7 +1969,7 @@ class HPE3PARBaseDriver(object):
model_update = self.driver.create_volume_from_snapshot(
volume,
self.snapshot)
self.assertEqual(None, model_update)
self.assertIsNone(model_update)
comment = (
'{"snapshot_id": "2f823bdc-e36e-4dc8-bd15-de1c7a28ff31",'
@ -2034,7 +2034,7 @@ class HPE3PARBaseDriver(object):
model_update = self.driver.create_volume_from_snapshot(
volume,
self.snapshot)
self.assertEqual(None, model_update)
self.assertIsNone(model_update)
comment = (
'{"snapshot_id": "2f823bdc-e36e-4dc8-bd15-de1c7a28ff31",'
@ -4144,12 +4144,12 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
stats['pools'][0]['goodness_function'])
self.assertEqual(FILTER_FUNCTION,
stats['pools'][0]['filter_function'])
self.assertEqual(None, stats['pools'][0][THROUGHPUT])
self.assertEqual(None, stats['pools'][0][BANDWIDTH])
self.assertEqual(None, stats['pools'][0][LATENCY])
self.assertEqual(None, stats['pools'][0][IO_SIZE])
self.assertEqual(None, stats['pools'][0][QUEUE_LENGTH])
self.assertEqual(None, stats['pools'][0][AVG_BUSY_PERC])
self.assertIsNone(stats['pools'][0][THROUGHPUT])
self.assertIsNone(stats['pools'][0][BANDWIDTH])
self.assertIsNone(stats['pools'][0][LATENCY])
self.assertIsNone(stats['pools'][0][IO_SIZE])
self.assertIsNone(stats['pools'][0][QUEUE_LENGTH])
self.assertIsNone(stats['pools'][0][AVG_BUSY_PERC])
expected = [
mock.call.getStorageSystemInfo(),
@ -4199,12 +4199,12 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
stats['pools'][0]['goodness_function'])
self.assertEqual(FILTER_FUNCTION,
stats['pools'][0]['filter_function'])
self.assertEqual(None, stats['pools'][0][THROUGHPUT])
self.assertEqual(None, stats['pools'][0][BANDWIDTH])
self.assertEqual(None, stats['pools'][0][LATENCY])
self.assertEqual(None, stats['pools'][0][IO_SIZE])
self.assertEqual(None, stats['pools'][0][QUEUE_LENGTH])
self.assertEqual(None, stats['pools'][0][AVG_BUSY_PERC])
self.assertIsNone(stats['pools'][0][THROUGHPUT])
self.assertIsNone(stats['pools'][0][BANDWIDTH])
self.assertIsNone(stats['pools'][0][LATENCY])
self.assertIsNone(stats['pools'][0][IO_SIZE])
self.assertIsNone(stats['pools'][0][QUEUE_LENGTH])
self.assertIsNone(stats['pools'][0][AVG_BUSY_PERC])
expected = [
mock.call.getStorageSystemInfo(),
@ -4854,12 +4854,12 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
stats['pools'][0]['goodness_function'])
self.assertEqual(FILTER_FUNCTION,
stats['pools'][0]['filter_function'])
self.assertEqual(None, stats['pools'][0][THROUGHPUT])
self.assertEqual(None, stats['pools'][0][BANDWIDTH])
self.assertEqual(None, stats['pools'][0][LATENCY])
self.assertEqual(None, stats['pools'][0][IO_SIZE])
self.assertEqual(None, stats['pools'][0][QUEUE_LENGTH])
self.assertEqual(None, stats['pools'][0][AVG_BUSY_PERC])
self.assertIsNone(stats['pools'][0][THROUGHPUT])
self.assertIsNone(stats['pools'][0][BANDWIDTH])
self.assertIsNone(stats['pools'][0][LATENCY])
self.assertIsNone(stats['pools'][0][IO_SIZE])
self.assertIsNone(stats['pools'][0][QUEUE_LENGTH])
self.assertIsNone(stats['pools'][0][AVG_BUSY_PERC])
expected = [
mock.call.getStorageSystemInfo(),
@ -4909,12 +4909,12 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
stats['pools'][0]['goodness_function'])
self.assertEqual(FILTER_FUNCTION,
stats['pools'][0]['filter_function'])
self.assertEqual(None, stats['pools'][0][THROUGHPUT])
self.assertEqual(None, stats['pools'][0][BANDWIDTH])
self.assertEqual(None, stats['pools'][0][LATENCY])
self.assertEqual(None, stats['pools'][0][IO_SIZE])
self.assertEqual(None, stats['pools'][0][QUEUE_LENGTH])
self.assertEqual(None, stats['pools'][0][AVG_BUSY_PERC])
self.assertIsNone(stats['pools'][0][THROUGHPUT])
self.assertIsNone(stats['pools'][0][BANDWIDTH])
self.assertIsNone(stats['pools'][0][LATENCY])
self.assertIsNone(stats['pools'][0][IO_SIZE])
self.assertIsNone(stats['pools'][0][QUEUE_LENGTH])
self.assertIsNone(stats['pools'][0][AVG_BUSY_PERC])
expected = [
mock.call.getStorageSystemInfo(),
@ -4961,8 +4961,8 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
mock_client.assert_has_calls(expected)
self.assertEqual(self.FAKE_HOST, host['name'])
self.assertEqual(None, auth_username)
self.assertEqual(None, auth_password)
self.assertIsNone(auth_username)
self.assertIsNone(auth_password)
def test_create_host_chap_enabled(self):
# setup_mock_client drive with CHAP enabled configuration
@ -5059,8 +5059,8 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
mock_client.assert_has_calls(expected)
self.assertEqual('fakehost.foo', host['name'])
self.assertEqual(None, auth_username)
self.assertEqual(None, auth_password)
self.assertIsNone(auth_username)
self.assertIsNone(auth_password)
def test_create_invalid_host_chap_enabled(self):
# setup_mock_client drive with CHAP enabled configuration
@ -5157,8 +5157,8 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
mock_client.assert_has_calls(expected)
self.assertEqual(self.FAKE_HOST, host['name'])
self.assertEqual(None, auth_username)
self.assertEqual(None, auth_password)
self.assertIsNone(auth_username)
self.assertIsNone(auth_password)
self.assertEqual(2, len(host['FCPaths']))
def test_create_modify_host_chap_enabled(self):

View File

@ -1200,9 +1200,8 @@ class FlashSystemDriverTestCase(test.TestCase):
self.assertEqual(
host2,
self.driver._find_host_exhaustive(conn2, [host1, host2]))
self.assertEqual(
None,
self.driver._find_host_exhaustive(conn3, [host1, host2]))
self.assertIsNone(self.driver._find_host_exhaustive(conn3,
[host1, host2]))
# clear environment
self.driver._delete_host(host1)
@ -1262,6 +1261,4 @@ class FlashSystemDriverTestCase(test.TestCase):
self.driver.delete_volume(vol2)
# case 4: If there is no vdisk mapped to host, host should be removed
self.assertEqual(
None,
self.driver._get_host_from_connector(self.connector))
self.assertIsNone(self.driver._get_host_from_connector(self.connector))

View File

@ -261,6 +261,4 @@ class FlashSystemISCSIDriverTestCase(test.TestCase):
self.driver.delete_volume(vol2)
# case 4: If there is no vdisk mapped to host, host should be removed
self.assertEqual(
None,
self.driver._get_host_from_connector(self.connector))
self.assertIsNone(self.driver._get_host_from_connector(self.connector))

View File

@ -163,7 +163,7 @@ class IBMNASDriverTestCase(test.TestCase):
drv = self._driver
mock_ssh.return_value = None
self.assertEqual(None, drv._ssh_operation('ssh_cmd'))
self.assertIsNone(drv._ssh_operation('ssh_cmd'))
@mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver._run_ssh')
def test_ssh_operation_exception(self, mock_ssh):
@ -186,9 +186,9 @@ class IBMNASDriverTestCase(test.TestCase):
mock_ssh.return_value = True
mock_execute.return_value = True
self.assertEqual(None, drv._create_ibmnas_snap(self.TEST_VOLUME_PATH,
self.TEST_SNAP_PATH,
self.TEST_MNT_POINT))
self.assertIsNone(drv._create_ibmnas_snap(self.TEST_VOLUME_PATH,
self.TEST_SNAP_PATH,
self.TEST_MNT_POINT))
@mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver.'
'_ssh_operation')
@ -201,9 +201,9 @@ class IBMNASDriverTestCase(test.TestCase):
mock_ssh.return_value = True
mock_execute.return_value = True
self.assertEqual(None, drv._create_ibmnas_snap(self.TEST_VOLUME_PATH,
self.TEST_SNAP_PATH,
self.TEST_MNT_POINT))
self.assertIsNone(drv._create_ibmnas_snap(self.TEST_VOLUME_PATH,
self.TEST_SNAP_PATH,
self.TEST_MNT_POINT))
@mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver.'
'_ssh_operation')
@ -213,9 +213,9 @@ class IBMNASDriverTestCase(test.TestCase):
drv = self._driver
mock_ssh.return_value = True
self.assertEqual(None, drv._create_ibmnas_snap(self.TEST_VOLUME_PATH,
self.TEST_SNAP_PATH,
None))
self.assertIsNone(drv._create_ibmnas_snap(self.TEST_VOLUME_PATH,
self.TEST_SNAP_PATH,
None))
@mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver.'
'_ssh_operation')
@ -359,7 +359,7 @@ class IBMNASDriverTestCase(test.TestCase):
volume['name'] = '/volume-123'
volume['provider_location'] = self.TEST_VOLUME_PATH
self.assertEqual(None, drv.delete_volume(volume))
self.assertIsNone(drv.delete_volume(volume))
@mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver.'
'_get_export_path')

View File

@ -498,7 +498,7 @@ class InfortrendFCCommonTestCase(InfortrendTestCass):
]
self._assert_cli_has_calls(expect_cli_cmd)
self.assertEqual(None, conn_info)
self.assertIsNone(conn_info)
class InfortrendiSCSICommonTestCase(InfortrendTestCass):

View File

@ -754,7 +754,7 @@ class NetAppEseriesISCSIDriverTestCase(test.TestCase):
pool = self.driver.get_pool({'name_id': 'fake-uuid'})
self.assertEqual(None, pool)
self.assertIsNone(pool)
@mock.patch.object(library.NetAppESeriesLibrary, '_create_volume',
mock.Mock())

View File

@ -2732,7 +2732,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
# in the parameter.
params = self.driver._get_vdisk_params(None, volume_type=None,
volume_metadata=None)
self.assertEqual(None, params['qos'])
self.assertIsNone(params['qos'])
qos_spec = volume_types.get_volume_type_qos_specs(type_id)
volume_types.destroy(self.ctxt, type_id)
qos_specs.delete(self.ctxt, qos_spec['qos_specs']['id'])
@ -2761,7 +2761,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
# in the parameter.
params = self.driver._get_vdisk_params(None, volume_type=None,
volume_metadata=None)
self.assertEqual(None, params['qos'])
self.assertIsNone(params['qos'])
volume_types.destroy(self.ctxt, type_id)
# If the QoS is set in the volume metadata,
@ -3062,8 +3062,8 @@ class StorwizeSVCDriverTestCase(test.TestCase):
self.driver._check_volume_copy_ops()
self.driver._rm_vdisk_copy_op(ctxt, volume, new_ops[0], new_ops[1])
admin_metadata = self.db.volume_admin_metadata_get(ctxt, volume['id'])
self.assertEqual(None, admin_metadata.get('vdiskcopyops', None),
'Storwize driver delete vdisk copy error')
self.assertIsNone(admin_metadata.get('vdiskcopyops', None),
'Storwize driver delete vdisk copy error')
self._delete_volume(volume)
def test_storwize_delete_with_vdisk_copy_ops(self):

View File

@ -142,7 +142,7 @@ class V6000CommonTestCase(test.TestCase):
self.driver.vip.version)
self.driver.vip.basic.get_node_values.assert_called_with(
[bn1, bn2])
self.assertEqual(None, result)
self.assertIsNone(result)
def test_check_for_setup_error_no_container(self):
"""No container was configured."""
@ -560,4 +560,4 @@ class V6000CommonTestCase(test.TestCase):
def test_fatal_error_code_non_fatal_error(self):
"""Returns no exception for a non-fatal error code."""
response = {'code': 1024, 'message': 'try again!'}
self.assertEqual(None, self.driver._fatal_error_code(response))
self.assertIsNone(self.driver._fatal_error_code(response))

View File

@ -410,7 +410,7 @@ class V7000FCPDriverTestCase(test.TestCase):
self.driver._build_initiator_target_map.assert_called_with(
CONNECTOR)
self.assertEqual("fibre_channel", props['driver_volume_type'])
self.assertEqual(True, props['data']['target_discovered'])
self.assertTrue(props['data']['target_discovered'])
self.assertEqual(self.driver.gateway_fc_wwns,
props['data']['target_wwn'])
self.assertEqual(lun_id, props['data']['target_lun'])

View File

@ -1968,8 +1968,8 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
volume = FakeObject()
volume['volume_type_id'] = None
sp = self._driver._get_storage_profile(volume)
self.assertEqual(None, sp, "Without a volume_type_id no storage "
"profile should be returned.")
self.assertIsNone(sp, "Without a volume_type_id no storage "
"profile should be returned.")
# profile associated with the volume type should be returned
fake_id = 'fake_volume_id'

View File

@ -727,8 +727,7 @@ class VolumeUtilsTestCase(test.TestCase):
volume_utils.extract_host(host, 'backend', True))
self.assertEqual(host,
volume_utils.extract_host(host, 'backend', False))
self.assertEqual(None,
volume_utils.extract_host(host, 'pool'))
self.assertIsNone(volume_utils.extract_host(host, 'pool'))
self.assertEqual('_pool0',
volume_utils.extract_host(host, 'pool', True))
@ -739,8 +738,7 @@ class VolumeUtilsTestCase(test.TestCase):
volume_utils.extract_host(host, 'host'))
self.assertEqual(host,
volume_utils.extract_host(host, 'backend'))
self.assertEqual(None,
volume_utils.extract_host(host, 'pool'))
self.assertIsNone(volume_utils.extract_host(host, 'pool'))
self.assertEqual('_pool0',
volume_utils.extract_host(host, 'pool', True))

View File

@ -95,7 +95,7 @@ class NetApp7modeClientTestCase(test.TestCase):
iqn = self.client.get_iscsi_service_details()
self.assertEqual(None, iqn)
self.assertIsNone(iqn)
def test_get_iscsi_service_details(self):
expected_iqn = 'iqn.1998-01.org.openstack.iscsi:name1'

View File

@ -103,7 +103,7 @@ class NetAppCmodeClientTestCase(test.TestCase):
iqn = self.client.get_iscsi_service_details()
self.assertEqual(None, iqn)
self.assertIsNone(iqn)
def test_get_iscsi_service_details(self):
expected_iqn = 'iqn.1998-01.org.openstack.iscsi:name1'
@ -819,9 +819,8 @@ class NetAppCmodeClientTestCase(test.TestCase):
self.assertEqual(expected_flex_vol, actual_flex_vol)
self.assertEqual(expected_src_path, actual_src_path)
self.assertEqual(expected_dest_path, actual_dest_path)
self.assertEqual(None,
actual_request.get_child_by_name(
'destination-exists'))
self.assertIsNone(actual_request.get_child_by_name(
'destination-exists'))
def test_get_file_usage(self):
expected_bytes = "2048"

View File

@ -421,13 +421,13 @@ class NetAppBlockStorage7modeLibraryTestCase(test.TestCase):
result = self.library._mark_qos_policy_group_for_deletion(
fake.QOS_POLICY_GROUP_INFO)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_setup_qos_for_volume(self):
result = self.library._setup_qos_for_volume(fake.VOLUME,
fake.EXTRA_SPECS)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_manage_existing_lun_same_name(self):
mock_lun = block_base.NetAppLun('handle', 'name', '1',

View File

@ -94,14 +94,14 @@ class NetAppBlockStorageLibraryTestCase(test.TestCase):
mock.Mock(return_value=None))
def test_get_pool_no_metadata(self):
pool = self.library.get_pool({'name': 'volume-fake-uuid'})
self.assertEqual(None, pool)
self.assertIsNone(pool)
@mock.patch.object(block_base.NetAppBlockStorageLibrary,
'_get_lun_attr',
mock.Mock(return_value=dict()))
def test_get_pool_volume_unknown(self):
pool = self.library.get_pool({'name': 'volume-fake-uuid'})
self.assertEqual(None, pool)
self.assertIsNone(pool)
def test_create_volume(self):
volume_size_in_bytes = int(fake.SIZE) * units.Gi
@ -617,7 +617,7 @@ class NetAppBlockStorageLibraryTestCase(test.TestCase):
result = self.library._get_preferred_target_from_list(
target_details_list)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_get_preferred_target_from_list_with_one_interface_disabled(self):
target_details_list = copy.deepcopy(fake.ISCSI_TARGET_DETAILS_LIST)

View File

@ -223,7 +223,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.map_qos_spec(qos_spec, fake.VOLUME)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_map_qos_spec_maxiops(self):
qos_spec = {'maxIOPs': 33000}
@ -285,7 +285,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_qos_policy_group_name(volume)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_get_qos_policy_group_name_from_info(self):
expected = 'openstack-%s' % fake.VOLUME_ID
@ -298,7 +298,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_qos_policy_group_name_from_info(None)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_get_qos_policy_group_name_from_legacy_info(self):
expected = fake.QOS_POLICY_GROUP_NAME
@ -404,7 +404,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_valid_backend_qos_spec_from_volume_type(
fake.VOLUME, fake.VOLUME_TYPE)
self.assertEqual(None, result)
self.assertIsNone(result)
self.assertEqual(0, mock_validate.call_count)
def test_get_valid_backend_qos_spec_from_volume_type(self):
@ -426,7 +426,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_backend_qos_spec_from_volume_type(volume_type)
self.assertEqual(None, result)
self.assertIsNone(result)
self.assertEqual(0, mock_get_context.call_count)
def test_get_backend_qos_spec_from_volume_type_no_qos_spec(self):
@ -437,7 +437,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_backend_qos_spec_from_volume_type(volume_type)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_get_backend_qos_spec_from_volume_type_with_frontend_spec(self):
volume_type = fake.VOLUME_TYPE
@ -447,7 +447,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_backend_qos_spec_from_volume_type(volume_type)
self.assertEqual(None, result)
self.assertIsNone(result)
def test_get_backend_qos_spec_from_volume_type_with_backend_spec(self):
volume_type = fake.VOLUME_TYPE
@ -489,7 +489,7 @@ class NetAppDriverUtilsTestCase(test.TestCase):
result = na_utils.get_legacy_qos_policy(extra_specs)
self.assertEqual(None, result)
self.assertIsNone(result)
class OpenStackInfoTestCase(test.TestCase):
@ -760,7 +760,7 @@ class FeaturesTestCase(test.TestCase):
self.assertEqual(value, bool(self.features.FEATURE_2))
self.assertEqual(value, self.features.FEATURE_2.supported)
self.assertEqual(None, self.features.FEATURE_2.minimum_version)
self.assertIsNone(self.features.FEATURE_2.minimum_version)
self.assertIn('FEATURE_2', self.features.defined_features)
@ddt.data((True, '1'), (False, 2), (False, None), (True, None))