Test patching booleans with string values
The baremetal client encodes boolean patch values as strings ("True", "False") but there is no unit test coverage which confirms that this actually works. This change adds that test coverage. Change-Id: I9e428ad973e88d3e1ef1e04e49a7b00a4e2d43fd
This commit is contained in:
parent
a3644ebd63
commit
32ab90b3b9
|
@ -3384,6 +3384,38 @@ class TestPatch(test_api_base.BaseApiTest):
|
|||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(http_client.OK, response.status_code)
|
||||
|
||||
def test_update_protected_string(self):
|
||||
node = obj_utils.create_test_node(self.context,
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
provision_state='active')
|
||||
self.mock_update_node.return_value = node
|
||||
headers = {api_base.Version.string: '1.48'}
|
||||
# Patch with valid boolean string
|
||||
response = self.patch_json('/nodes/%s' % node.uuid,
|
||||
[{'path': '/protected',
|
||||
'value': "True",
|
||||
'op': 'replace'}],
|
||||
headers=headers)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(http_client.OK, response.status_code)
|
||||
|
||||
def test_update_protected_string_invalid(self):
|
||||
node = obj_utils.create_test_node(self.context,
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
provision_state='active')
|
||||
self.mock_update_node.return_value = node
|
||||
headers = {api_base.Version.string: '1.48'}
|
||||
# Patch with invalid boolean string
|
||||
response = self.patch_json('/nodes/%s' % node.uuid,
|
||||
[{'path': '/protected',
|
||||
'value': "YeahNahGood",
|
||||
'op': 'replace'}],
|
||||
headers=headers,
|
||||
expect_errors=True)
|
||||
self.assertEqual(http_client.BAD_REQUEST, response.status_code)
|
||||
self.assertIn("Invalid protected: Unrecognized value 'YeahNahGood'",
|
||||
response.json['error_message'])
|
||||
|
||||
def test_update_protected_remove(self):
|
||||
node = obj_utils.create_test_node(self.context,
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
|
|
Loading…
Reference in New Issue