Merge "Fix clearing of dns_domain and description on a network by setting to empty strings"
This commit is contained in:
commit
4bafc32616
@ -107,7 +107,7 @@ def _get_attrs_network(client_manager, parsed_args):
|
|||||||
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
|
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
|
||||||
|
|
||||||
# set description
|
# set description
|
||||||
if parsed_args.description:
|
if parsed_args.description is not None:
|
||||||
attrs['description'] = parsed_args.description
|
attrs['description'] = parsed_args.description
|
||||||
|
|
||||||
# set mtu
|
# set mtu
|
||||||
@ -139,7 +139,7 @@ def _get_attrs_network(client_manager, parsed_args):
|
|||||||
if 'no_qos_policy' in parsed_args and parsed_args.no_qos_policy:
|
if 'no_qos_policy' in parsed_args and parsed_args.no_qos_policy:
|
||||||
attrs['qos_policy_id'] = None
|
attrs['qos_policy_id'] = None
|
||||||
# Update DNS network options
|
# Update DNS network options
|
||||||
if parsed_args.dns_domain:
|
if parsed_args.dns_domain is not None:
|
||||||
attrs['dns_domain'] = parsed_args.dns_domain
|
attrs['dns_domain'] = parsed_args.dns_domain
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
@ -1063,6 +1063,39 @@ class TestSetNetwork(TestNetwork):
|
|||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_set_to_empty(self):
|
||||||
|
# Test if empty strings are accepted to clear any of the fields,
|
||||||
|
# so once they are set to a value its possible to clear them again.
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
self._network.name,
|
||||||
|
'--name',
|
||||||
|
'',
|
||||||
|
'--description',
|
||||||
|
'',
|
||||||
|
'--dns-domain',
|
||||||
|
'',
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('network', self._network.name),
|
||||||
|
('description', ''),
|
||||||
|
('name', ''),
|
||||||
|
('dns_domain', ''),
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
attrs = {
|
||||||
|
'name': '',
|
||||||
|
'description': '',
|
||||||
|
'dns_domain': '',
|
||||||
|
}
|
||||||
|
self.network_client.update_network.assert_called_once_with(
|
||||||
|
self._network, **attrs
|
||||||
|
)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_set_nothing(self):
|
def test_set_nothing(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
self._network.name,
|
self._network.name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user