@@ -110,6 +110,7 @@ class TestCreateSubnet(TestSubnet):
110110 columns = (
111111 'allocation_pools' ,
112112 'cidr' ,
113+ 'description' ,
113114 'dns_nameservers' ,
114115 'enable_dhcp' ,
115116 'gateway_ip' ,
@@ -129,6 +130,7 @@ class TestCreateSubnet(TestSubnet):
129130 data = (
130131 subnet_v2 ._format_allocation_pools (_subnet .allocation_pools ),
131132 _subnet .cidr ,
133+ _subnet .description ,
132134 utils .format_list (_subnet .dns_nameservers ),
133135 _subnet .enable_dhcp ,
134136 _subnet .gateway_ip ,
@@ -148,6 +150,7 @@ class TestCreateSubnet(TestSubnet):
148150 data_subnet_pool = (
149151 subnet_v2 ._format_allocation_pools (_subnet_from_pool .allocation_pools ),
150152 _subnet_from_pool .cidr ,
153+ _subnet_from_pool .description ,
151154 utils .format_list (_subnet_from_pool .dns_nameservers ),
152155 _subnet_from_pool .enable_dhcp ,
153156 _subnet_from_pool .gateway_ip ,
@@ -167,6 +170,7 @@ class TestCreateSubnet(TestSubnet):
167170 data_ipv6 = (
168171 subnet_v2 ._format_allocation_pools (_subnet_ipv6 .allocation_pools ),
169172 _subnet_ipv6 .cidr ,
173+ _subnet_ipv6 .description ,
170174 utils .format_list (_subnet_ipv6 .dns_nameservers ),
171175 _subnet_ipv6 .enable_dhcp ,
172176 _subnet_ipv6 .gateway_ip ,
@@ -427,6 +431,40 @@ def test_create_with_network_segment(self):
427431 self .assertEqual (self .columns , columns )
428432 self .assertEqual (self .data , data )
429433
434+ def test_create_with_description (self ):
435+ # Mock SDK calls for this test.
436+ self .network .create_subnet = mock .Mock (return_value = self ._subnet )
437+ self ._network .id = self ._subnet .network_id
438+
439+ arglist = [
440+ "--subnet-range" , self ._subnet .cidr ,
441+ "--network" , self ._subnet .network_id ,
442+ "--description" , self ._subnet .description ,
443+ self ._subnet .name ,
444+ ]
445+ verifylist = [
446+ ('name' , self ._subnet .name ),
447+ ('description' , self ._subnet .description ),
448+ ('subnet_range' , self ._subnet .cidr ),
449+ ('network' , self ._subnet .network_id ),
450+ ('ip_version' , self ._subnet .ip_version ),
451+ ('gateway' , 'auto' ),
452+
453+ ]
454+
455+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
456+ columns , data = self .cmd .take_action (parsed_args )
457+
458+ self .network .create_subnet .assert_called_once_with (** {
459+ 'cidr' : self ._subnet .cidr ,
460+ 'ip_version' : self ._subnet .ip_version ,
461+ 'name' : self ._subnet .name ,
462+ 'network_id' : self ._subnet .network_id ,
463+ 'description' : self ._subnet .description ,
464+ })
465+ self .assertEqual (self .columns , columns )
466+ self .assertEqual (self .data , data )
467+
430468
431469class TestDeleteSubnet (TestSubnet ):
432470
@@ -876,6 +914,30 @@ def test_append_options(self):
876914 _testsubnet , ** attrs )
877915 self .assertIsNone (result )
878916
917+ def test_set_non_append_options (self ):
918+ arglist = [
919+ "--description" , "new_description" ,
920+ "--dhcp" ,
921+ "--gateway" , self ._subnet .gateway_ip ,
922+ self ._subnet .name ,
923+ ]
924+ verifylist = [
925+ ('description' , "new_description" ),
926+ ('dhcp' , True ),
927+ ('gateway' , self ._subnet .gateway_ip ),
928+ ('subnet' , self ._subnet .name ),
929+ ]
930+
931+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
932+ result = self .cmd .take_action (parsed_args )
933+ attrs = {
934+ 'enable_dhcp' : True ,
935+ 'gateway_ip' : self ._subnet .gateway_ip ,
936+ 'description' : "new_description" ,
937+ }
938+ self .network .update_subnet .assert_called_with (self ._subnet , ** attrs )
939+ self .assertIsNone (result )
940+
879941
880942class TestShowSubnet (TestSubnet ):
881943 # The subnets to be shown
@@ -884,6 +946,7 @@ class TestShowSubnet(TestSubnet):
884946 columns = (
885947 'allocation_pools' ,
886948 'cidr' ,
949+ 'description' ,
887950 'dns_nameservers' ,
888951 'enable_dhcp' ,
889952 'gateway_ip' ,
@@ -903,6 +966,7 @@ class TestShowSubnet(TestSubnet):
903966 data = (
904967 subnet_v2 ._format_allocation_pools (_subnet .allocation_pools ),
905968 _subnet .cidr ,
969+ _subnet .description ,
906970 utils .format_list (_subnet .dns_nameservers ),
907971 _subnet .enable_dhcp ,
908972 _subnet .gateway_ip ,
0 commit comments