@@ -698,3 +698,42 @@ def test_show_all_options(self):
698698 )
699699 self .assertEqual (self .columns , columns )
700700 self .assertEqual (self .data , data )
701+
702+
703+ class TestUnsetSubnetPool (TestSubnetPool ):
704+
705+ def setUp (self ):
706+ super (TestUnsetSubnetPool , self ).setUp ()
707+ self ._subnetpool = network_fakes .FakeSubnetPool .create_one_subnet_pool (
708+ {'prefixes' : ['10.0.10.0/24' , '10.1.10.0/24' ,
709+ '10.2.10.0/24' ], })
710+ self .network .find_subnet_pool = mock .Mock (
711+ return_value = self ._subnetpool )
712+ self .network .update_subnet_pool = mock .Mock (return_value = None )
713+ # Get the command object to test
714+ self .cmd = subnet_pool .UnsetSubnetPool (self .app , self .namespace )
715+
716+ def test_unset_subnet_pool (self ):
717+ arglist = [
718+ '--pool-prefix' , '10.0.10.0/24' ,
719+ '--pool-prefix' , '10.1.10.0/24' ,
720+ self ._subnetpool .name ,
721+ ]
722+ verifylist = [('prefixes' , ['10.0.10.0/24' , '10.1.10.0/24' ])]
723+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
724+ result = self .cmd .take_action (parsed_args )
725+ attrs = {'prefixes' : ['10.2.10.0/24' ]}
726+ self .network .update_subnet_pool .assert_called_once_with (
727+ self ._subnetpool , ** attrs )
728+ self .assertIsNone (result )
729+
730+ def test_unset_subnet_pool_prefix_not_existent (self ):
731+ arglist = [
732+ '--pool-prefix' , '10.100.1.1/25' ,
733+ self ._subnetpool .name ,
734+ ]
735+ verifylist = [('prefixes' , ['10.100.1.1/25' ])]
736+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
737+ self .assertRaises (exceptions .CommandError ,
738+ self .cmd .take_action ,
739+ parsed_args )
0 commit comments