From a1f2f4af5831fc47a7efea61163643dc8b6c0bc8 Mon Sep 17 00:00:00 2001 From: reedip Date: Tue, 1 Mar 2016 16:11:51 +0900 Subject: [PATCH] TrivialOrder: Rearrange Class Names As per the comment given by Steve Martinelli in https://review.openstack.org/#/c/278209/ , the following patch just rearranges the classes as per the Alphabetical order. TrivialFix Change-Id: Ib8f0f703df4ef7d7ee6180ff8bd8a47062ae5b0f --- doc/source/command-objects/subnet.rst | 32 +++++----- openstackclient/network/v2/subnet.py | 36 ++++++------ .../tests/network/v2/test_subnet.py | 58 +++++++++---------- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/doc/source/command-objects/subnet.rst b/doc/source/command-objects/subnet.rst index 9520a22d6a..97d5c68b89 100644 --- a/doc/source/command-objects/subnet.rst +++ b/doc/source/command-objects/subnet.rst @@ -4,6 +4,22 @@ subnet Network v2 +subnet delete +------------- + +Delete a subnet + +.. program:: subnet delete +.. code:: bash + + os subnet delete + + +.. _subnet_delete-subnet: +.. describe:: + + Subnet to delete (name or ID) + subnet list ----------- @@ -34,19 +50,3 @@ Show subnet details .. describe:: Subnet to show (name or ID) - -subnet delete -------------- - -Delete a subnet - -.. program:: subnet delete -.. code:: bash - - os subnet delete - - -.. _subnet_delete-subnet: -.. describe:: - - Subnet to delete (name or ID) diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py index 96ab35ae74..b514a88f7d 100644 --- a/openstackclient/network/v2/subnet.py +++ b/openstackclient/network/v2/subnet.py @@ -38,6 +38,24 @@ def _get_columns(item): return tuple(sorted(columns)) +class DeleteSubnet(command.Command): + """Delete subnet""" + + def get_parser(self, prog_name): + parser = super(DeleteSubnet, self).get_parser(prog_name) + parser.add_argument( + 'subnet', + metavar="", + help="Subnet to delete (name or ID)" + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.network + client.delete_subnet( + client.find_subnet(parsed_args.subnet)) + + class ListSubnet(command.Lister): """List subnets""" @@ -89,21 +107,3 @@ class ShowSubnet(command.ShowOne): columns = _get_columns(obj) data = utils.get_item_properties(obj, columns, formatters=_formatters) return (columns, data) - - -class DeleteSubnet(command.Command): - """Delete subnet""" - - def get_parser(self, prog_name): - parser = super(DeleteSubnet, self).get_parser(prog_name) - parser.add_argument( - 'subnet', - metavar="", - help=("Subnet to delete (name or ID)") - ) - return parser - - def take_action(self, parsed_args): - client = self.app.client_manager.network - client.delete_subnet( - client.find_subnet(parsed_args.subnet)) diff --git a/openstackclient/tests/network/v2/test_subnet.py b/openstackclient/tests/network/v2/test_subnet.py index e844c1388b..a95635ffad 100644 --- a/openstackclient/tests/network/v2/test_subnet.py +++ b/openstackclient/tests/network/v2/test_subnet.py @@ -28,6 +28,35 @@ class TestSubnet(network_fakes.TestNetworkV2): self.network = self.app.client_manager.network +class TestDeleteSubnet(TestSubnet): + + # The subnet to delete. + _subnet = network_fakes.FakeSubnet.create_one_subnet() + + def setUp(self): + super(TestDeleteSubnet, self).setUp() + + self.network.delete_subnet = mock.Mock(return_value=None) + + self.network.find_subnet = mock.Mock(return_value=self._subnet) + + # Get the command object to test + self.cmd = subnet_v2.DeleteSubnet(self.app, self.namespace) + + def test_delete(self): + arglist = [ + self._subnet.name, + ] + verifylist = [ + ('subnet', self._subnet.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + self.network.delete_subnet.assert_called_with(self._subnet) + self.assertIsNone(result) + + class TestListSubnet(TestSubnet): # The subnets going to be listed up. _subnet = network_fakes.FakeSubnet.create_subnets(count=3) @@ -181,32 +210,3 @@ class TestShowSubnet(TestSubnet): self.assertEqual(self.columns, columns) self.assertEqual(list(self.data), list(data)) - - -class TestDeleteSubnet(TestSubnet): - - # The subnet to delete. - _subnet = network_fakes.FakeSubnet.create_one_subnet() - - def setUp(self): - super(TestDeleteSubnet, self).setUp() - - self.network.delete_subnet = mock.Mock(return_value=None) - - self.network.find_subnet = mock.Mock(return_value=self._subnet) - - # Get the command object to test - self.cmd = subnet_v2.DeleteSubnet(self.app, self.namespace) - - def test_delete(self): - arglist = [ - self._subnet.name, - ] - verifylist = [ - ('subnet', self._subnet.name), - ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - result = self.cmd.take_action(parsed_args) - self.network.delete_subnet.assert_called_with(self._subnet) - self.assertIsNone(result)