Add helper method for testing node fields
This adds a helper method '_test_node_fields_hidden_in_lower_version()) to provide consistency and reduce the amount of copy/paste being used for several of the unit tests. Change-Id: I3d319cd1711fe10e9c92ab2076b9b415b7f3810c
This commit is contained in:
parent
15b2be4eef
commit
3f94f5d224
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user