@@ -28,6 +28,35 @@ def setUp(self):
2828 self .network = self .app .client_manager .network
2929
3030
31+ class TestDeleteSubnet (TestSubnet ):
32+
33+ # The subnet to delete.
34+ _subnet = network_fakes .FakeSubnet .create_one_subnet ()
35+
36+ def setUp (self ):
37+ super (TestDeleteSubnet , self ).setUp ()
38+
39+ self .network .delete_subnet = mock .Mock (return_value = None )
40+
41+ self .network .find_subnet = mock .Mock (return_value = self ._subnet )
42+
43+ # Get the command object to test
44+ self .cmd = subnet_v2 .DeleteSubnet (self .app , self .namespace )
45+
46+ def test_delete (self ):
47+ arglist = [
48+ self ._subnet .name ,
49+ ]
50+ verifylist = [
51+ ('subnet' , self ._subnet .name ),
52+ ]
53+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
54+
55+ result = self .cmd .take_action (parsed_args )
56+ self .network .delete_subnet .assert_called_with (self ._subnet )
57+ self .assertIsNone (result )
58+
59+
3160class TestListSubnet (TestSubnet ):
3261 # The subnets going to be listed up.
3362 _subnet = network_fakes .FakeSubnet .create_subnets (count = 3 )
@@ -181,32 +210,3 @@ def test_show_all_options(self):
181210
182211 self .assertEqual (self .columns , columns )
183212 self .assertEqual (list (self .data ), list (data ))
184-
185-
186- class TestDeleteSubnet (TestSubnet ):
187-
188- # The subnet to delete.
189- _subnet = network_fakes .FakeSubnet .create_one_subnet ()
190-
191- def setUp (self ):
192- super (TestDeleteSubnet , self ).setUp ()
193-
194- self .network .delete_subnet = mock .Mock (return_value = None )
195-
196- self .network .find_subnet = mock .Mock (return_value = self ._subnet )
197-
198- # Get the command object to test
199- self .cmd = subnet_v2 .DeleteSubnet (self .app , self .namespace )
200-
201- def test_delete (self ):
202- arglist = [
203- self ._subnet .name ,
204- ]
205- verifylist = [
206- ('subnet' , self ._subnet .name ),
207- ]
208- parsed_args = self .check_parser (self .cmd , arglist , verifylist )
209-
210- result = self .cmd .take_action (parsed_args )
211- self .network .delete_subnet .assert_called_with (self ._subnet )
212- self .assertIsNone (result )
0 commit comments