File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ def _get_attrs_network(client_manager, parsed_args):
107107 attrs ['availability_zone_hints' ] = parsed_args .availability_zone_hints
108108
109109 # set description
110- if parsed_args .description :
110+ if parsed_args .description is not None :
111111 attrs ['description' ] = parsed_args .description
112112
113113 # set mtu
@@ -139,7 +139,7 @@ def _get_attrs_network(client_manager, parsed_args):
139139 if 'no_qos_policy' in parsed_args and parsed_args .no_qos_policy :
140140 attrs ['qos_policy_id' ] = None
141141 # Update DNS network options
142- if parsed_args .dns_domain :
142+ if parsed_args .dns_domain is not None :
143143 attrs ['dns_domain' ] = parsed_args .dns_domain
144144 return attrs
145145
Original file line number Diff line number Diff line change @@ -1063,6 +1063,39 @@ def test_set_that(self):
10631063 )
10641064 self .assertIsNone (result )
10651065
1066+ def test_set_to_empty (self ):
1067+ # Test if empty strings are accepted to clear any of the fields,
1068+ # so once they are set to a value its possible to clear them again.
1069+
1070+ arglist = [
1071+ self ._network .name ,
1072+ '--name' ,
1073+ '' ,
1074+ '--description' ,
1075+ '' ,
1076+ '--dns-domain' ,
1077+ '' ,
1078+ ]
1079+ verifylist = [
1080+ ('network' , self ._network .name ),
1081+ ('description' , '' ),
1082+ ('name' , '' ),
1083+ ('dns_domain' , '' ),
1084+ ]
1085+
1086+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1087+ result = self .cmd .take_action (parsed_args )
1088+
1089+ attrs = {
1090+ 'name' : '' ,
1091+ 'description' : '' ,
1092+ 'dns_domain' : '' ,
1093+ }
1094+ self .network_client .update_network .assert_called_once_with (
1095+ self ._network , ** attrs
1096+ )
1097+ self .assertIsNone (result )
1098+
10661099 def test_set_nothing (self ):
10671100 arglist = [
10681101 self ._network .name ,
You can’t perform that action at this time.
0 commit comments