Replace dict.get(key) in api & conductor tests
This replaces dict.get(key) with dict[key] in tests/unit/api & tests/unit/conductor, since we should be explicit about whether we expect the key to exist or not. In particular, we shouldn't be doing self.assertIsNone(dict.get(key)) since it will pass if 1. the value is None or 2. if the key isn't in the dict. For the case of 2, .assertIsNone() is replaced with .assertNotIn(). Change-Id: Ia305a221389e39d759b0881620c200c625fc98e1 Closes-Bug: #1590808
This commit is contained in:
parent
50cc15eabd
commit
8e95cdf8ec
@ -536,8 +536,7 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
|
||||
def test_associated_nodes_insensitive(self):
|
||||
associated_nodes = (self
|
||||
._create_association_test_nodes()
|
||||
.get('associated'))
|
||||
._create_association_test_nodes()['associated'])
|
||||
|
||||
data = self.get_json('/nodes?associated=true')
|
||||
data1 = self.get_json('/nodes?associated=True')
|
||||
@ -555,9 +554,8 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_unassociated_nodes_insensitive(self):
|
||||
unassociated_nodes = (self
|
||||
._create_association_test_nodes()
|
||||
.get('unassociated'))
|
||||
unassociated_nodes = (
|
||||
self._create_association_test_nodes()['unassociated'])
|
||||
|
||||
data = self.get_json('/nodes?associated=false')
|
||||
data1 = self.get_json('/nodes?associated=FALSE')
|
||||
@ -568,9 +566,8 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
self.assertEqual(sorted(unassociated_nodes), sorted(uuids))
|
||||
|
||||
def test_unassociated_nodes_with_limit(self):
|
||||
unassociated_nodes = (self
|
||||
._create_association_test_nodes()
|
||||
.get('unassociated'))
|
||||
unassociated_nodes = (
|
||||
self._create_association_test_nodes()['unassociated'])
|
||||
|
||||
data = self.get_json('/nodes?associated=False&limit=2')
|
||||
|
||||
@ -585,8 +582,7 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
|
||||
def test_detail_with_association_filter(self):
|
||||
associated_nodes = (self
|
||||
._create_association_test_nodes()
|
||||
.get('associated'))
|
||||
._create_association_test_nodes()['associated'])
|
||||
data = self.get_json('/nodes/detail?associated=true')
|
||||
self.assertIn('driver', data['nodes'][0])
|
||||
self.assertEqual(len(associated_nodes), len(data['nodes']))
|
||||
|
@ -1491,7 +1491,7 @@ class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin,
|
||||
# Node will be moved to CLEANING
|
||||
self.assertEqual(states.CLEANING, node.provision_state)
|
||||
self.assertEqual(states.MANAGEABLE, node.target_provision_state)
|
||||
self.assertIsNone(node.driver_internal_info.get('clean_steps'))
|
||||
self.assertNotIn('clean_steps', node.driver_internal_info)
|
||||
self.assertIsNone(node.last_error)
|
||||
|
||||
@mock.patch('ironic.conductor.manager.ConductorManager._spawn_worker')
|
||||
@ -1719,8 +1719,8 @@ class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin,
|
||||
self.assertEqual(states.AVAILABLE, node.provision_state)
|
||||
self.assertEqual(states.NOSTATE, node.target_provision_state)
|
||||
self.assertEqual({}, node.clean_step)
|
||||
self.assertIsNone(node.driver_internal_info.get('clean_steps'))
|
||||
self.assertIsNone(node.driver_internal_info.get('clean_step_index'))
|
||||
self.assertNotIn('clean_steps', node.driver_internal_info)
|
||||
self.assertNotIn('clean_step_index', node.driver_internal_info)
|
||||
|
||||
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare_cleaning')
|
||||
def __do_node_clean_prepare_clean_fail(self, mock_prep, clean_steps=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user