allow property set of empty string
- allow property value to be set to an empty string - fix pep8 doc issue - if a double quote makes it into the property value, throw as this will cause property list to later throw an exception. (property set foo "" is not a problem as the quotes are stripped off. But property set foo \" is a problem.) - add utest for setting empty string Jira-Issue: OPENSTACK-986
This commit is contained in:
parent
0bb430d7ee
commit
76aa503aa6
|
@ -47,8 +47,7 @@ class ClientApi(
|
|||
ServiceApi,
|
||||
SupportApi,
|
||||
):
|
||||
"""
|
||||
Client API Notes
|
||||
"""Client API Notes
|
||||
|
||||
Objects returned by the API contain a local copy of the information
|
||||
in the datastore. While changes made to the local copy will be
|
||||
|
|
|
@ -78,7 +78,10 @@ class PropertyApi(object):
|
|||
"""
|
||||
for key, value in property_dict.items():
|
||||
check_arg(key, u._('Property Key'), str)
|
||||
check_arg(value, u._('Property Value'), str)
|
||||
check_arg(value, u._('Property Value'), str, empty_ok=True)
|
||||
if '"' in value:
|
||||
raise InvalidArgument(u._('Cannot use double quotes in '
|
||||
'a property value.'))
|
||||
property_dict = safe_decode(property_dict)
|
||||
|
||||
self._check_type(property_type)
|
||||
|
|
|
@ -198,6 +198,20 @@ class TestFunctional(KollaCliTest):
|
|||
'(%s %s)'
|
||||
% (switch, targets_csv))
|
||||
|
||||
# test setting empty string
|
||||
value = '""'
|
||||
self.run_cli_cmd('property set %s %s %s %s'
|
||||
% (switch, targets_csv, key, value))
|
||||
msg = self.run_cli_cmd('property list --all -f json %s %s'
|
||||
% (switch, targets_csv))
|
||||
err_msg = self._check_property_values(key, value, msg, targets)
|
||||
self.assertTrue('missing' in err_msg,
|
||||
'clear failed, property still in output: ' +
|
||||
'%s, %s (%s %s)'
|
||||
% (key, value, switch, targets_csv))
|
||||
self.run_cli_cmd('property clear %s %s %s'
|
||||
% (switch, targets_csv, key))
|
||||
|
||||
def _check_property_values(self, key, value, json_str,
|
||||
targets=[]):
|
||||
"""Verify cli data against model data"""
|
||||
|
|
Loading…
Reference in New Issue