99 lines
4.8 KiB
Diff
99 lines
4.8 KiB
Diff
diff --git a/ironic/api/controllers/v1/utils.py b/ironic/api/controllers/v1/utils.py
|
|
index 2949325..5c13d2a 100644
|
|
--- a/ironic/api/controllers/v1/utils.py
|
|
+++ b/ironic/api/controllers/v1/utils.py
|
|
@@ -42,7 +42,8 @@ from ironic import objects
|
|
CONF = cfg.CONF
|
|
|
|
|
|
-_JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchException,
|
|
+_JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchConflict,
|
|
+ jsonpatch.JsonPatchException,
|
|
jsonpatch.JsonPointerException,
|
|
KeyError,
|
|
IndexError)
|
|
diff --git a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py
|
|
index 049a21f..d30b763 100644
|
|
--- a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py
|
|
+++ b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py
|
|
@@ -361,7 +361,8 @@ class TestPatch(BaseDeployTemplatesAPITest):
|
|
self.assertEqual('application/json', response.content_type)
|
|
self.assertEqual(http_client.BAD_REQUEST, response.status_code)
|
|
self.assertTrue(response.json['error_message'])
|
|
- self.assertIn(error_msg, response.json['error_message'])
|
|
+ #self.assertIn(error_msg, response.json['error_message'])
|
|
+ self.assertRegex(response.json['error_message'], error_msg)
|
|
self.assertFalse(mock_save.called)
|
|
return response
|
|
|
|
@@ -539,7 +540,8 @@ class TestPatch(BaseDeployTemplatesAPITest):
|
|
}
|
|
patch = [{'path': '/steps/1', 'op': 'replace', 'value': step}]
|
|
self._test_update_bad_request(
|
|
- mock_save, patch, "list assignment index out of range")
|
|
+ mock_save, patch, "list assignment index out of range|"
|
|
+ "can't replace outside of list")
|
|
|
|
def test_replace_empty_step_list_fail(self, mock_save):
|
|
patch = [{'path': '/steps', 'op': 'replace', 'value': []}]
|
|
@@ -567,7 +569,7 @@ class TestPatch(BaseDeployTemplatesAPITest):
|
|
|
|
def test_remove_foo(self, mock_save):
|
|
self._test_remove_not_allowed(
|
|
- mock_save, 'foo', "can't remove non-existent object 'foo'")
|
|
+ mock_save, 'foo', "can't remove a non-existent object 'foo'")
|
|
|
|
def test_replace_step_invalid_interface(self, mock_save):
|
|
patch = [{'path': '/steps/0/interface', 'op': 'replace',
|
|
@@ -634,12 +636,12 @@ class TestPatch(BaseDeployTemplatesAPITest):
|
|
patch = [{'path': '/non-existent', 'op': 'remove'}]
|
|
self._test_update_bad_request(
|
|
mock_save, patch,
|
|
- "can't remove non-existent object 'non-existent'")
|
|
+ "can't remove a non-existent object 'non-existent'")
|
|
|
|
def test_remove_non_existent_step_fail(self, mock_save):
|
|
patch = [{'path': '/steps/1', 'op': 'remove'}]
|
|
self._test_update_bad_request(
|
|
- mock_save, patch, "can't remove non-existent object '1'")
|
|
+ mock_save, patch, "can't remove a non-existent object '1'")
|
|
|
|
def test_remove_only_step_fail(self, mock_save):
|
|
patch = [{'path': '/steps/0', 'op': 'remove'}]
|
|
@@ -650,12 +652,12 @@ class TestPatch(BaseDeployTemplatesAPITest):
|
|
patch = [{'path': '/steps/0/non-existent', 'op': 'remove'}]
|
|
self._test_update_bad_request(
|
|
mock_save, patch,
|
|
- "can't remove non-existent object 'non-existent'")
|
|
+ "can't remove a non-existent object 'non-existent'")
|
|
|
|
def test_add_root_non_existent(self, mock_save):
|
|
patch = [{'path': '/foo', 'value': 'bar', 'op': 'add'}]
|
|
self._test_update_bad_request(
|
|
- mock_save, patch, "Adding a new attribute (/foo)")
|
|
+ mock_save, patch, "Adding a new attribute \(/foo\)")
|
|
|
|
def test_add_too_high_index_step_fail(self, mock_save):
|
|
step = {
|
|
diff --git a/ironic/tests/unit/api/controllers/v1/test_utils.py b/ironic/tests/unit/api/controllers/v1/test_utils.py
|
|
index d18fded..1c7d842 100644
|
|
--- a/ironic/tests/unit/api/controllers/v1/test_utils.py
|
|
+++ b/ironic/tests/unit/api/controllers/v1/test_utils.py
|
|
@@ -105,7 +105,7 @@ class TestApiUtils(base.TestCase):
|
|
doc = {}
|
|
patch = [{"op": "remove", "path": "/foo"}]
|
|
self.assertRaisesRegex(exception.PatchError,
|
|
- "can't remove non-existent object 'foo'",
|
|
+ "can't remove a non-existent object 'foo'",
|
|
utils.apply_jsonpatch, doc, patch)
|
|
|
|
def test_apply_jsonpatch_replace_non_existent_list_item(self):
|
|
@@ -113,6 +113,7 @@ class TestApiUtils(base.TestCase):
|
|
doc = []
|
|
patch = [{"op": "replace", "path": "/0", "value": 42}]
|
|
self.assertRaisesRegex(exception.PatchError,
|
|
+ "can't replace outside of list|"
|
|
"list assignment index out of range",
|
|
utils.apply_jsonpatch, doc, patch)
|
|
|