From c3db17c05e0a9c6754c23d6375e57607bd86e83a Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 29 Apr 2015 14:27:14 +0100 Subject: [PATCH] Add stub commands and tests for all OpenStack client commands This adds the overall stubs for all the Tuskar commands that will be added to the OpenStack client. Change-Id: Ia3d465f253aedb5825a9db552b560e50945c9bf7 --- setup.cfg | 14 +++ tuskarclient/osc/v2/__init__.py | 0 tuskarclient/osc/v2/plan.py | 121 ++++++++++++++++++++ tuskarclient/osc/v2/role.py | 28 +++++ tuskarclient/tests/osc/__init__.py | 0 tuskarclient/tests/osc/v2/__init__.py | 0 tuskarclient/tests/osc/v2/fakes.py | 22 ++++ tuskarclient/tests/osc/v2/test_plans.py | 143 ++++++++++++++++++++++++ tuskarclient/tests/osc/v2/test_roles.py | 38 +++++++ 9 files changed, 366 insertions(+) create mode 100644 tuskarclient/osc/v2/__init__.py create mode 100644 tuskarclient/osc/v2/plan.py create mode 100644 tuskarclient/osc/v2/role.py create mode 100644 tuskarclient/tests/osc/__init__.py create mode 100644 tuskarclient/tests/osc/v2/__init__.py create mode 100644 tuskarclient/tests/osc/v2/fakes.py create mode 100644 tuskarclient/tests/osc/v2/test_plans.py create mode 100644 tuskarclient/tests/osc/v2/test_roles.py diff --git a/setup.cfg b/setup.cfg index edbc757..4ca226c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,20 @@ packages = console_scripts = tuskar = tuskarclient.shell:main +openstack.cli.extension = + management = tuskarclient.osc.plugin + +openstack.management.v2 = + management_plan_create = tuskarclient.osc.v2.plan:CreateManagementPlan + management_plan_delete = tuskarclient.osc.v2.plan:DeleteManagementPlan + management_plan_list = tuskarclient.osc.v2.plan:ListManagementPlans + management_plan_set = tuskarclient.osc.v2.plan:SetManagementPlan + management_plan_show = tuskarclient.osc.v2.plan:ShowManagementPlan + management_plan_add_role = tuskarclient.osc.v2.plan:AddManagementPlanRole + management_plan_remove_role = tuskarclient.osc.v2.plan:RemoveManagementPlanRole + management_plan_download = tuskarclient.osc.v2.plan:DownloadManagementPlan + management_role_list = tuskarclient.osc.v2.role:ListRoles + [build_sphinx] source-dir = doc/source build-dir = doc/build diff --git a/tuskarclient/osc/v2/__init__.py b/tuskarclient/osc/v2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tuskarclient/osc/v2/plan.py b/tuskarclient/osc/v2/plan.py new file mode 100644 index 0000000..cab2d8d --- /dev/null +++ b/tuskarclient/osc/v2/plan.py @@ -0,0 +1,121 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging + +from cliff import command +from cliff import lister +from cliff import show + + +class CreateManagementPlan(show.ShowOne): + """Create a Management Plan.""" + + log = logging.getLogger(__name__ + '.CreateManagementPlan') + + def get_parser(self, prog_name): + parser = super(CreateManagementPlan, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class DeleteManagementPlan(command.Command): + """Delete a Management Plan.""" + + log = logging.getLogger(__name__ + '.DeleteManagementPlan') + + def get_parser(self, prog_name): + parser = super(DeleteManagementPlan, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class ListManagementPlans(lister.Lister): + """List the Management Plans.""" + + log = logging.getLogger(__name__ + '.ListManagementPlans') + + def get_parser(self, prog_name): + parser = super(ListManagementPlans, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class SetManagementPlan(show.ShowOne): + """Update a Management Plans properties.""" + + log = logging.getLogger(__name__ + '.SetManagementPlan') + + def get_parser(self, prog_name): + parser = super(SetManagementPlan, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class ShowManagementPlan(show.ShowOne): + """Show a Management Plan.""" + + log = logging.getLogger(__name__ + '.ShowManagementPlan') + + def get_parser(self, prog_name): + parser = super(ShowManagementPlan, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class AddManagementPlanRole(show.ShowOne): + """Add a Role to a Management Plan.""" + + log = logging.getLogger(__name__ + '.AddManagementPlanRole') + + def get_parser(self, prog_name): + parser = super(AddManagementPlanRole, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class RemoveManagementPlanRole(show.ShowOne): + """Remove a Role from a Management Plan.""" + + log = logging.getLogger(__name__ + '.RemoveManagementPlanRole') + + def get_parser(self, prog_name): + parser = super(RemoveManagementPlanRole, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + + +class DownloadManagementPlan(command.Command): + """Download the a Management Plan.""" + + log = logging.getLogger(__name__ + '.DownloadManagementPlan') + + def get_parser(self, prog_name): + parser = super(DownloadManagementPlan, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) diff --git a/tuskarclient/osc/v2/role.py b/tuskarclient/osc/v2/role.py new file mode 100644 index 0000000..a4defa7 --- /dev/null +++ b/tuskarclient/osc/v2/role.py @@ -0,0 +1,28 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging + +from cliff import lister + + +class ListRoles(lister.Lister): + """List Roles.""" + + log = logging.getLogger(__name__ + '.ListRoles') + + def get_parser(self, prog_name): + parser = super(ListRoles, self).get_parser(prog_name) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) diff --git a/tuskarclient/tests/osc/__init__.py b/tuskarclient/tests/osc/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tuskarclient/tests/osc/v2/__init__.py b/tuskarclient/tests/osc/v2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tuskarclient/tests/osc/v2/fakes.py b/tuskarclient/tests/osc/v2/fakes.py new file mode 100644 index 0000000..e9e314b --- /dev/null +++ b/tuskarclient/tests/osc/v2/fakes.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock +from openstackclient.tests import utils + + +class TestManagement(utils.TestCommand): + + def setUp(self): + super(TestManagement, self).setUp() + + self.app.client_manager.management = mock.Mock() diff --git a/tuskarclient/tests/osc/v2/test_plans.py b/tuskarclient/tests/osc/v2/test_plans.py new file mode 100644 index 0000000..c53c1c6 --- /dev/null +++ b/tuskarclient/tests/osc/v2/test_plans.py @@ -0,0 +1,143 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tuskarclient.osc.v2 import plan +from tuskarclient.tests.osc.v2 import fakes + + +class TestPlans(fakes.TestManagement): + + def setUp(self): + super(TestPlans, self).setUp() + + self.management_mock = self.app.client_manager.management + self.management_mock.reset_mock() + + +class TestCreateManagementPlan(TestPlans): + + def setUp(self): + super(TestCreateManagementPlan, self).setUp() + self.cmd = plan.CreateManagementPlan(self.app, None) + + def test_create_plan(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestDeleteManagementPlan(TestPlans): + + def setUp(self): + super(TestDeleteManagementPlan, self).setUp() + self.cmd = plan.DeleteManagementPlan(self.app, None) + + def test_delete_plan(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestListManagementPlan(TestPlans): + + def setUp(self): + super(TestListManagementPlan, self).setUp() + self.cmd = plan.ListManagementPlans(self.app, None) + + def test_list_plans(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestSetManagementPlan(TestPlans): + + def setUp(self): + super(TestSetManagementPlan, self).setUp() + self.cmd = plan.SetManagementPlan(self.app, None) + + def test_update_plan(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestShowManagementPlan(TestPlans): + + def setUp(self): + super(TestShowManagementPlan, self).setUp() + self.cmd = plan.ShowManagementPlan(self.app, None) + + def test_show_plan(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestAddManagementPlanRole(TestPlans): + + def setUp(self): + super(TestAddManagementPlanRole, self).setUp() + self.cmd = plan.AddManagementPlanRole(self.app, None) + + def test_add_plan_role(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestRemoveManagementPlanRole(TestPlans): + + def setUp(self): + super(TestRemoveManagementPlanRole, self).setUp() + self.cmd = plan.RemoveManagementPlanRole(self.app, None) + + def test_remove_plan_role(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + +class TestDownloadManagementPlan(TestPlans): + + def setUp(self): + super(TestDownloadManagementPlan, self).setUp() + self.cmd = plan.DownloadManagementPlan(self.app, None) + + def test_download_plan_templates(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) diff --git a/tuskarclient/tests/osc/v2/test_roles.py b/tuskarclient/tests/osc/v2/test_roles.py new file mode 100644 index 0000000..268d2a0 --- /dev/null +++ b/tuskarclient/tests/osc/v2/test_roles.py @@ -0,0 +1,38 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tuskarclient.osc.v2 import role +from tuskarclient.tests.osc.v2 import fakes + + +class TestRoles(fakes.TestManagement): + + def setUp(self): + super(TestRoles, self).setUp() + + self.management_mock = self.app.client_manager.management + self.management_mock.reset_mock() + + +class TestRoleList(TestRoles): + + def setUp(self): + super(TestRoleList, self).setUp() + self.cmd = role.ListRoles(self.app, None) + + def test_list_roles(self): + arglist = [] + verifylist = [] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args)