Add unit tests that "remove" is acceptable on /XXX_interface node fields

This feature is a side effect of how driver_factory works, but it proved
quite useful, so let's unit test it to avoid regressions.

Change-Id: I12f018ae823dfe85b2eac8a77ea5073fda7c2982
Story: #2002868
Task: #22827
This commit is contained in:
Dmitry Tantsur 2018-07-05 15:40:42 +02:00
parent beefb770e7
commit 8608d3420b

View File

@ -2223,6 +2223,18 @@ class TestPatch(test_api_base.BaseApiTest):
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code)
def test_reset_network_interface(self):
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())
self.mock_update_node.return_value = node
headers = {api_base.Version.string: str(api_v1.max_version())}
response = self.patch_json('/nodes/%s' % node.uuid,
[{'path': '/network_interface',
'op': 'remove'}],
headers=headers)
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code)
def test_update_network_interface_old_api(self):
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())
@ -2310,6 +2322,20 @@ class TestPatch(test_api_base.BaseApiTest):
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code)
def test_reset_interface_fields(self):
# Using remove on an interface resets it to its default
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())
self.mock_update_node.return_value = node
headers = {api_base.Version.string: str(api_v1.max_version())}
for field in api_utils.V31_FIELDS:
response = self.patch_json('/nodes/%s' % node.uuid,
[{'path': '/%s' % field,
'op': 'remove'}],
headers=headers)
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code)
def test_update_interface_fields_bad_version(self):
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())
@ -2339,6 +2365,18 @@ class TestPatch(test_api_base.BaseApiTest):
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code)
def test_reset_storage_interface(self):
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())
self.mock_update_node.return_value = node
headers = {api_base.Version.string: str(api_v1.max_version())}
response = self.patch_json('/nodes/%s' % node.uuid,
[{'path': '/storage_interface',
'op': 'remove'}],
headers=headers)
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.OK, response.status_code)
def test_update_storage_interface_old_api(self):
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())