summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--magnumclient/common/utils.py8
-rw-r--r--magnumclient/tests/v1/test_clustertemplates_shell.py9
2 files changed, 16 insertions, 1 deletions
diff --git a/magnumclient/common/utils.py b/magnumclient/common/utils.py
index 57ce02e..af5642f 100644
--- a/magnumclient/common/utils.py
+++ b/magnumclient/common/utils.py
@@ -78,7 +78,13 @@ def args_array_to_patch(op, attributes):
78 attr = '/' + attr 78 attr = '/' + attr
79 if op in ['add', 'replace']: 79 if op in ['add', 'replace']:
80 path, value = split_and_deserialize(attr) 80 path, value = split_and_deserialize(attr)
81 patch.append({'op': op, 'path': path, 'value': value}) 81 if path == "/labels":
82 a = []
83 a.append(value)
84 value = str(handle_labels(a))
85 patch.append({'op': op, 'path': path, 'value': value})
86 else:
87 patch.append({'op': op, 'path': path, 'value': value})
82 88
83 elif op == "remove": 89 elif op == "remove":
84 # For remove only the key is needed 90 # For remove only the key is needed
diff --git a/magnumclient/tests/v1/test_clustertemplates_shell.py b/magnumclient/tests/v1/test_clustertemplates_shell.py
index bb53ff6..67bce87 100644
--- a/magnumclient/tests/v1/test_clustertemplates_shell.py
+++ b/magnumclient/tests/v1/test_clustertemplates_shell.py
@@ -681,6 +681,15 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
681 681
682 @mock.patch( 682 @mock.patch(
683 'magnumclient.v1.cluster_templates.ClusterTemplateManager.update') 683 'magnumclient.v1.cluster_templates.ClusterTemplateManager.update')
684 def test_cluster_template_update_label(self, mock_update):
685 self._test_arg_success('cluster-template-update test '
686 'replace labels=key1=val1')
687 patch = [{'op': 'replace', 'path': '/labels',
688 'value': "{'key1': 'val1'}"}]
689 mock_update.assert_called_once_with('test', patch)
690
691 @mock.patch(
692 'magnumclient.v1.cluster_templates.ClusterTemplateManager.update')
684 def test_cluster_template_update_failure_wrong_op(self, mock_update): 693 def test_cluster_template_update_failure_wrong_op(self, mock_update):
685 _error_msg = [ 694 _error_msg = [
686 '.*?^usage: magnum cluster-template-update ', 695 '.*?^usage: magnum cluster-template-update ',