Merge "Add helper method for testing node fields"

This commit is contained in:
Zuul 2018-06-27 21:24:00 +00:00 committed by Gerrit Code Review
commit c45d3c1399

View File

@ -198,13 +198,20 @@ class TestListNodes(test_api_base.BaseApiTest):
headers={api_base.Version.string: str(api_v1.max_version())}) headers={api_base.Version.string: str(api_v1.max_version())})
self.assertEqual(node.uuid, data['uuid']) self.assertEqual(node.uuid, data['uuid'])
def test_node_states_field_hidden_in_lower_version(self): def _test_node_field_hidden_in_lower_version(self, field,
node = obj_utils.create_test_node(self.context, old_version, new_version):
chassis_id=self.chassis.id) node = obj_utils.create_test_node(self.context)
data = self.get_json( data = self.get_json(
'/nodes/%s' % node.uuid, '/nodes/%s' % node.uuid,
headers={api_base.Version.string: '1.8'}) headers={api_base.Version.string: old_version})
self.assertNotIn('states', data) self.assertNotIn(field, data)
data = self.get_json(
'/nodes/%s' % node.uuid,
headers={api_base.Version.string: new_version})
self.assertIn(field, data)
def test_node_states_field_hidden_in_lower_version(self):
self._test_node_field_hidden_in_lower_version('states', '1.8', '1.14')
def test_node_interface_fields_hidden_in_lower_version(self): def test_node_interface_fields_hidden_in_lower_version(self):
node = obj_utils.create_test_node(self.context) node = obj_utils.create_test_node(self.context)
@ -215,26 +222,15 @@ class TestListNodes(test_api_base.BaseApiTest):
self.assertNotIn(field, data) self.assertNotIn(field, data)
def test_node_storage_interface_hidden_in_lower_version(self): def test_node_storage_interface_hidden_in_lower_version(self):
node = obj_utils.create_test_node(self.context, self._test_node_field_hidden_in_lower_version('storage_interface',
storage_interface='cinder') '1.32', '1.33')
data = self.get_json(
'/nodes/%s' % node.uuid,
headers={api_base.Version.string: '1.32'})
self.assertNotIn('storage_interface', data)
def test_node_traits_hidden_in_lower_version(self): def test_node_traits_hidden_in_lower_version(self):
node = obj_utils.create_test_node(self.context) self._test_node_field_hidden_in_lower_version('traits', '1.36', '1.37')
data = self.get_json(
'/nodes/%s' % node.uuid,
headers={api_base.Version.string: '1.36'})
self.assertNotIn('traits', data)
def test_node_bios_hidden_in_lower_version(self): def test_node_bios_hidden_in_lower_version(self):
node = obj_utils.create_test_node(self.context) self._test_node_field_hidden_in_lower_version('bios_interface',
data = self.get_json( '1.39', '1.40')
'/nodes/%s' % node.uuid,
headers={api_base.Version.string: '1.39'})
self.assertNotIn('bios_interface', data)
def test_node_inspect_wait_state_between_api_versions(self): def test_node_inspect_wait_state_between_api_versions(self):
node = obj_utils.create_test_node(self.context, node = obj_utils.create_test_node(self.context,
@ -251,15 +247,8 @@ class TestListNodes(test_api_base.BaseApiTest):
higher_version_data['provision_state']) higher_version_data['provision_state'])
def test_node_fault_hidden_in_lower_version(self): def test_node_fault_hidden_in_lower_version(self):
node = obj_utils.create_test_node(self.context) self._test_node_field_hidden_in_lower_version('fault',
data = self.get_json( '1.41', '1.42')
'/nodes/%s' % node.uuid,
headers={api_base.Version.string: '1.41'})
self.assertNotIn('fault', data)
data = self.get_json(
'/nodes/%s' % node.uuid,
headers={api_base.Version.string: '1.42'})
self.assertIn('fault', data)
def test_get_one_custom_fields(self): def test_get_one_custom_fields(self):
node = obj_utils.create_test_node(self.context, node = obj_utils.create_test_node(self.context,