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
This commit is contained in:
Dougal Matthews 2015-04-29 14:27:14 +01:00
parent 3b822e309f
commit c3db17c05e
9 changed files with 366 additions and 0 deletions

View File

@ -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

View File

121
tuskarclient/osc/v2/plan.py Normal file
View File

@ -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)

View File

@ -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)

View File

View File

View File

@ -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()

View File

@ -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)

View File

@ -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)