Merge "Use more specific asserts in tests"

This commit is contained in:
Jenkins 2017-08-04 13:00:19 +00:00 committed by Gerrit Code Review
commit 6f1cf41ffe
11 changed files with 28 additions and 28 deletions

View File

@ -52,12 +52,12 @@ class TestExposedAPIMethodsCheckPolicy(test_base.TestCase):
for func in self.exposed_methods: for func in self.exposed_methods:
src = inspect.getsource(func) src = inspect.getsource(func)
self.assertTrue('policy.authorize' in src, self.assertIn('policy.authorize', src,
'policy.authorize call not found in exposed ' 'policy.authorize call not found in exposed '
'method %s' % func) 'method %s' % func)
self.assertTrue('context.to_policy_values' in src, self.assertIn('context.to_policy_values', src,
'context.to_policy_values call not found in ' 'context.to_policy_values call not found in '
'exposed method %s' % func) 'exposed method %s' % func)
def test_chasis_api_policy(self): def test_chasis_api_policy(self):
self._test('ironic.api.controllers.v1.chassis') self._test('ironic.api.controllers.v1.chassis')

View File

@ -147,7 +147,7 @@ class APINotifyTestCase(tests_base.TestCase):
self.assertEqual('11:22:33:77:88:99', payload.address) self.assertEqual('11:22:33:77:88:99', payload.address)
self.assertEqual({'a': 25}, payload.local_link_connection) self.assertEqual({'a': 25}, payload.local_link_connection)
self.assertEqual({'as': 34}, payload.extra) self.assertEqual({'as': 34}, payload.extra)
self.assertEqual(False, payload.pxe_enabled) self.assertIs(False, payload.pxe_enabled)
def test_portgroup_notification(self): def test_portgroup_notification(self):
node_uuid = uuidutils.generate_uuid() node_uuid = uuidutils.generate_uuid()

View File

@ -855,7 +855,7 @@ class TestPatch(test_api_base.BaseApiTest):
headers=self.headers) headers=self.headers)
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code) self.assertEqual(http_client.OK, response.status_code)
self.assertEqual(False, response.json['standalone_ports_supported']) self.assertIs(False, response.json['standalone_ports_supported'])
def test_update_portgroup_standalone_ports_supported_bad_api_version( def test_update_portgroup_standalone_ports_supported_bad_api_version(
self, mock_upd): self, mock_upd):

View File

@ -32,7 +32,7 @@ class StatesTest(base.TestCase):
# Assumption: A state variable name is all UPPERCASE and contents # Assumption: A state variable name is all UPPERCASE and contents
# are a string. # are a string.
if key.upper() == key and isinstance(value, six.string_types): if key.upper() == key and isinstance(value, six.string_types):
self.assertTrue( self.assertLessEqual(
(len(value) <= 15), len(value), 15,
"Value for state: {} is greater than 15 characters".format( "Value for state: {} is greater than 15 characters".format(
key)) key))

View File

@ -139,7 +139,7 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase):
self.assertEqual(['42'], self.assertEqual(['42'],
self.node.driver_internal_info['raid_config_job_ids']) self.node.driver_internal_info['raid_config_job_ids'])
self.assertEqual({}, self.node.raid_config) self.assertEqual({}, self.node.raid_config)
self.assertEqual(False, self.node.maintenance) self.assertIs(False, self.node.maintenance)
@mock.patch.object(drac_common, 'get_drac_client', spec_set=True, @mock.patch.object(drac_common, 'get_drac_client', spec_set=True,
autospec=True) autospec=True)

View File

@ -390,7 +390,7 @@ class IloManagementTestCase(db_base.DbTestCase):
'fw_location_for_another_filepath', 'chassis'), 'fw_location_for_another_filepath', 'chassis'),
] ]
clean_step_mock.assert_has_calls(calls) clean_step_mock.assert_has_calls(calls)
self.assertTrue(clean_step_mock.call_count == 5) self.assertEqual(5, clean_step_mock.call_count)
def test_update_firmware_throws_if_invalid_update_mode_provided(self): def test_update_firmware_throws_if_invalid_update_mode_provided(self):
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,

View File

@ -240,7 +240,7 @@ class OneViewPeriodicTasks(db_base.DbTestCase):
self.assertTrue(self.node.maintenance) self.assertTrue(self.node.maintenance)
self.assertEqual(common.NODE_IN_USE_BY_ONEVIEW, self.assertEqual(common.NODE_IN_USE_BY_ONEVIEW,
self.node.maintenance_reason) self.node.maintenance_reason)
self.assertFalse('oneview_error' in self.node.driver_internal_info) self.assertNotIn('oneview_error', self.node.driver_internal_info)
def test_node_stay_clean_failed_when_no_oneview_error( def test_node_stay_clean_failed_when_no_oneview_error(
self, mock_is_node_in_use_by_oneview, mock_node_get self, mock_is_node_in_use_by_oneview, mock_node_get
@ -256,7 +256,7 @@ class OneViewPeriodicTasks(db_base.DbTestCase):
self.assertFalse(self.node.maintenance) self.assertFalse(self.node.maintenance)
self.assertNotEqual(common.NODE_IN_USE_BY_ONEVIEW, self.assertNotEqual(common.NODE_IN_USE_BY_ONEVIEW,
self.node.maintenance_reason) self.node.maintenance_reason)
self.assertFalse('oneview_error' in self.node.driver_internal_info) self.assertNotIn('oneview_error', self.node.driver_internal_info)
@mock.patch.object(common, 'get_oneview_client', spec_set=True, autospec=True) @mock.patch.object(common, 'get_oneview_client', spec_set=True, autospec=True)

View File

@ -110,12 +110,12 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
'/rest/server-profiles/1234556789' '/rest/server-profiles/1234556789'
task.node.driver_info = driver_info task.node.driver_info = driver_info
self.assertTrue( self.assertIn(
'applied_server_profile_uri' in task.node.driver_info 'applied_server_profile_uri', task.node.driver_info
) )
deploy_utils.tear_down(ov_client, task) deploy_utils.tear_down(ov_client, task)
self.assertFalse( self.assertNotIn(
'applied_server_profile_uri' in task.node.driver_info 'applied_server_profile_uri', task.node.driver_info
) )
self.assertTrue( self.assertTrue(
ov_client.delete_server_profile.called ov_client.delete_server_profile.called
@ -403,8 +403,8 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
oneview_client, task.node oneview_client, task.node
) )
self.assertTrue(oneview_client.delete_server_profile.called) self.assertTrue(oneview_client.delete_server_profile.called)
self.assertTrue( self.assertNotIn(
'applied_server_profile_uri' not in task.node.driver_info 'applied_server_profile_uri', task.node.driver_info
) )
@mock.patch.object(objects.Node, 'save') @mock.patch.object(objects.Node, 'save')
@ -439,6 +439,6 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
task.node task.node
) )
self.assertTrue(ov_client.delete_server_profile.called) self.assertTrue(ov_client.delete_server_profile.called)
self.assertTrue( self.assertIn(
'applied_server_profile_uri' in task.node.driver_info 'applied_server_profile_uri', task.node.driver_info
) )

View File

@ -1625,9 +1625,9 @@ class AgentMethodsTestCase(db_base.DbTestCase):
utils.agent_add_clean_params(task) utils.agent_add_clean_params(task)
self.assertEqual(2, task.node.driver_internal_info[ self.assertEqual(2, task.node.driver_internal_info[
'agent_erase_devices_iterations']) 'agent_erase_devices_iterations'])
self.assertEqual(False, task.node.driver_internal_info[ self.assertIs(False, task.node.driver_internal_info[
'agent_erase_devices_zeroize']) 'agent_erase_devices_zeroize'])
self.assertEqual(True, task.node.driver_internal_info[ self.assertIs(True, task.node.driver_internal_info[
'agent_continue_if_ata_erase_failed']) 'agent_continue_if_ata_erase_failed'])
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk', autospec=True) @mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk', autospec=True)
@ -1649,8 +1649,8 @@ class AgentMethodsTestCase(db_base.DbTestCase):
power_mock.assert_called_once_with(task, states.REBOOT) power_mock.assert_called_once_with(task, states.REBOOT)
self.assertEqual(1, task.node.driver_internal_info[ self.assertEqual(1, task.node.driver_internal_info[
'agent_erase_devices_iterations']) 'agent_erase_devices_iterations'])
self.assertEqual(True, task.node.driver_internal_info[ self.assertIs(True, task.node.driver_internal_info[
'agent_erase_devices_zeroize']) 'agent_erase_devices_zeroize'])
if manage_boot: if manage_boot:
prepare_ramdisk_mock.assert_called_once_with( prepare_ramdisk_mock.assert_called_once_with(
mock.ANY, mock.ANY, {'a': 'b'}) mock.ANY, mock.ANY, {'a': 'b'})

View File

@ -2057,7 +2057,7 @@ class IPMIToolDriverTestCase(db_base.DbTestCase):
self.info['force_boot_device'] = True self.info['force_boot_device'] = True
self.driver.management.set_boot_device(task, boot_devices.PXE) self.driver.management.set_boot_device(task, boot_devices.PXE)
task.node.refresh() task.node.refresh()
self.assertEqual( self.assertIs(
False, False,
task.node.driver_internal_info['is_next_boot_persistent'] task.node.driver_internal_info['is_next_boot_persistent']
) )

View File

@ -169,7 +169,7 @@ class UtilsTestCase(db_base.DbTestCase):
ret = driver_utils.force_persistent_boot(task, 'pxe', False) ret = driver_utils.force_persistent_boot(task, 'pxe', False)
self.assertIsNone(ret) self.assertIsNone(ret)
task.node.refresh() task.node.refresh()
self.assertEqual( self.assertIs(
False, False,
task.node.driver_internal_info['is_next_boot_persistent']) task.node.driver_internal_info['is_next_boot_persistent'])