Prepare for Identity v3 tests

* Split identity/fakes.py for v2_0 and v3
* Split identity/test_identity.py for v2_0 and v3
* Fix issues in commands with enable/disable
* Clean up v2 commands

Change-Id: I6e536b6a130fc556dbd7dcf9f2e76d939ca1bc1c
This commit is contained in:
Dean Troyer 2013-09-09 14:52:45 -05:00
parent 16edd97007
commit 7a0a7d67ed
12 changed files with 222 additions and 141 deletions

View File

@ -33,7 +33,7 @@ class CreateProject(show.ShowOne):
def get_parser(self, prog_name):
parser = super(CreateProject, self).get_parser(prog_name)
parser.add_argument(
'project_name',
'name',
metavar='<project-name>',
help='New project name',
)
@ -57,13 +57,14 @@ class CreateProject(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
enabled = True
if parsed_args.disable:
enabled = False
project = identity_client.tenants.create(
parsed_args.project_name,
parsed_args.name,
description=parsed_args.description,
enabled=enabled,
)
@ -90,10 +91,12 @@ class DeleteProject(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
project = utils.find_resource(
identity_client.tenants,
parsed_args.project,
)
identity_client.tenants.delete(project.id)
return
@ -164,8 +167,14 @@ class SetProject(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
if (not parsed_args.name
and not parsed_args.description
and not parsed_args.enable
and not parsed_args.disable):
return
project = utils.find_resource(
identity_client.tenants,
parsed_args.project,
@ -180,7 +189,6 @@ class SetProject(command.Command):
kwargs['enabled'] = True
if parsed_args.disable:
kwargs['enabled'] = False
if 'id' in kwargs:
del kwargs['id']
if 'name' in kwargs:
@ -188,8 +196,8 @@ class SetProject(command.Command):
kwargs['tenant_name'] = kwargs['name']
del kwargs['name']
if len(kwargs):
identity_client.tenants.update(project.id, **kwargs)
identity_client.tenants.update(project.id, **kwargs)
return
class ShowProject(show.ShowOne):

View File

@ -28,7 +28,7 @@ from openstackclient.common import utils
class CreateService(show.ShowOne):
"""Create service command"""
"""Create new service"""
log = logging.getLogger(__name__ + '.CreateService')
@ -37,21 +37,25 @@ class CreateService(show.ShowOne):
parser.add_argument(
'name',
metavar='<service-name>',
help='New service name')
help='New service name',
)
parser.add_argument(
'--type',
metavar='<service-type>',
required=True,
help='New service type')
help='New service type (compute, image, identity, volume, etc)',
)
parser.add_argument(
'--description',
metavar='<service-description>',
help='New service description')
help='New service description',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
service = identity_client.services.create(
parsed_args.name,
parsed_args.type,
@ -63,7 +67,7 @@ class CreateService(show.ShowOne):
class DeleteService(command.Command):
"""Delete service command"""
"""Delete service"""
log = logging.getLogger(__name__ + '.DeleteService')
@ -71,19 +75,26 @@ class DeleteService(command.Command):
parser = super(DeleteService, self).get_parser(prog_name)
parser.add_argument(
'service',
metavar='<service-id>',
help='ID of service to delete')
metavar='<service>',
help='Service to delete (name or ID)',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
identity_client.services.delete(parsed_args.service)
service = utils.find_resource(
identity_client.services,
parsed_args.service,
)
identity_client.services.delete(service.id)
return
class ListService(lister.Lister):
"""List service command"""
"""List services"""
log = logging.getLogger(__name__ + '.ListService')
@ -98,6 +109,7 @@ class ListService(lister.Lister):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
if parsed_args.long:
columns = ('ID', 'Name', 'Type', 'Description')
else:
@ -111,7 +123,7 @@ class ListService(lister.Lister):
class ShowService(show.ShowOne):
"""Show cloud service information"""
"""Show service details"""
log = logging.getLogger(__name__ + '.ShowService')
@ -120,7 +132,7 @@ class ShowService(show.ShowOne):
parser.add_argument(
'service',
metavar='<service>',
help='Type, name or ID of service to display',
help='Service to display (type, name or ID)',
)
parser.add_argument(
'--catalog',

View File

@ -26,7 +26,7 @@ from openstackclient.common import utils
class CreateUser(show.ShowOne):
"""Create user command"""
"""Create new user"""
log = logging.getLogger(__name__ + '.CreateUser')
@ -35,15 +35,18 @@ class CreateUser(show.ShowOne):
parser.add_argument(
'name',
metavar='<user-name>',
help='New user name')
help='New user name',
)
parser.add_argument(
'--password',
metavar='<user-password>',
help='New user password')
help='New user password',
)
parser.add_argument(
'--email',
metavar='<user-email>',
help='New user email address')
help='New user email address',
)
parser.add_argument(
'--project',
metavar='<project>',
@ -65,6 +68,7 @@ class CreateUser(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
if parsed_args.project:
project_id = utils.find_resource(
identity_client.tenants,
@ -72,9 +76,11 @@ class CreateUser(show.ShowOne):
).id
else:
project_id = None
enabled = True
if parsed_args.disable:
enabled = False
user = identity_client.users.create(
parsed_args.name,
parsed_args.password,
@ -95,7 +101,7 @@ class CreateUser(show.ShowOne):
class DeleteUser(command.Command):
"""Delete user command"""
"""Delete user"""
log = logging.getLogger(__name__ + '.DeleteUser')
@ -104,19 +110,25 @@ class DeleteUser(command.Command):
parser.add_argument(
'user',
metavar='<user>',
help='Name or ID of user to delete')
help='User to delete (name or ID)',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
user = utils.find_resource(identity_client.users, parsed_args.user)
user = utils.find_resource(
identity_client.users,
parsed_args.user,
)
identity_client.users.delete(user.id)
return
class ListUser(lister.Lister):
"""List user command"""
"""List users"""
log = logging.getLogger(__name__ + '.ListUser')
@ -191,7 +203,7 @@ class ListUser(lister.Lister):
class SetUser(command.Command):
"""Set user command"""
"""Set user properties"""
log = logging.getLogger(__name__ + '.SetUser')
@ -200,19 +212,23 @@ class SetUser(command.Command):
parser.add_argument(
'user',
metavar='<user>',
help='Name or ID of user to change')
help='User to change (name or ID)',
)
parser.add_argument(
'--name',
metavar='<new-user-name>',
help='New user name')
help='New user name',
)
parser.add_argument(
'--password',
metavar='<user-password>',
help='New user password')
help='New user password',
)
parser.add_argument(
'--email',
metavar='<user-email>',
help='New user email address')
help='New user email address',
)
parser.add_argument(
'--project',
metavar='<project>',
@ -233,9 +249,21 @@ class SetUser(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
user = utils.find_resource(identity_client.users, parsed_args.user)
if (not parsed_args.name
and not parsed_args.name
and not parsed_args.password
and not parsed_args.email
and not parsed_args.project
and not parsed_args.enable
and not parsed_args.disable):
return
user = utils.find_resource(
identity_client.users,
parsed_args.user,
)
if parsed_args.password:
identity_client.users.update_password(
@ -258,17 +286,18 @@ class SetUser(command.Command):
kwargs['name'] = parsed_args.name
if parsed_args.email:
kwargs['email'] = parsed_args.email
kwargs['enabled'] = user.enabled
if parsed_args.enable:
kwargs['enabled'] = True
if parsed_args.disable:
kwargs['enabled'] = False
if len(kwargs):
identity_client.users.update(user.id, **kwargs)
identity_client.users.update(user.id, **kwargs)
return
class ShowUser(show.ShowOne):
"""Show user command"""
"""Show user details"""
log = logging.getLogger(__name__ + '.ShowUser')
@ -277,13 +306,19 @@ class ShowUser(show.ShowOne):
parser.add_argument(
'user',
metavar='<user>',
help='Name or ID of user to display')
help='User to display (name or ID)',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
user = utils.find_resource(identity_client.users, parsed_args.user)
user = utils.find_resource(
identity_client.users,
parsed_args.user,
)
if 'tenantId' in user._info:
user._info.update(
{'project_id': user._info.pop('tenantId')}

View File

@ -42,7 +42,11 @@ class FakeApp(object):
class FakeClientManager(object):
def __init__(self):
pass
self.compute = None
self.identity = None
self.image = None
self.volume = None
self.auth_ref = None
class FakeResource(object):

View File

@ -1,50 +0,0 @@
# Copyright 2013 OpenStack, LLC.
#
# 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 openstackclient.common import clientmanager
from openstackclient.identity import client as identity_client
from openstackclient.tests import utils
AUTH_TOKEN = "foobar"
AUTH_URL = "http://0.0.0.0"
class TestIdentity(utils.TestCommand):
def setUp(self):
super(TestIdentity, self).setUp()
api_version = {"identity": "2.0"}
identity_client.API_VERSIONS = {
"2.0": "openstackclient.tests.identity.fakes.FakeIdentityv2Client"
}
self.app.client_manager = clientmanager.ClientManager(
token=AUTH_TOKEN,
url=AUTH_URL,
auth_url=AUTH_URL,
api_version=api_version,
)
def test_make_client(self):
self.assertEqual(
self.app.client_manager.identity.auth_token,
AUTH_TOKEN,
)
self.assertEqual(
self.app.client_manager.identity.management_url,
AUTH_URL,
)

View File

@ -83,13 +83,3 @@ class FakeIdentityv2Client(object):
self.ec2.resource_class = fakes.FakeResource(None, {})
self.auth_token = kwargs['token']
self.management_url = kwargs['endpoint']
class FakeIdentityv3Client(object):
def __init__(self, **kwargs):
self.domains = mock.Mock()
self.domains.resource_class = fakes.FakeResource(None, {})
self.projects = mock.Mock()
self.projects.resource_class = fakes.FakeResource(None, {})
self.users = mock.Mock()
self.users.resource_class = fakes.FakeResource(None, {})

View File

@ -0,0 +1,31 @@
# Copyright 2013 Nebula Inc.
#
# 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 openstackclient.tests.identity.v2_0 import fakes
from openstackclient.tests import utils
AUTH_TOKEN = "foobar"
AUTH_URL = "http://0.0.0.0"
class TestIdentityv2(utils.TestCommand):
def setUp(self):
super(TestIdentityv2, self).setUp()
self.app.client_manager.identity = fakes.FakeIdentityv2Client(
endpoint=AUTH_URL,
token=AUTH_TOKEN,
)

View File

@ -17,11 +17,11 @@ import copy
from openstackclient.identity.v2_0 import project
from openstackclient.tests import fakes
from openstackclient.tests.identity import fakes as identity_fakes
from openstackclient.tests.identity import test_identity
from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
from openstackclient.tests.identity.v2_0 import test_identity
class TestProject(test_identity.TestIdentity):
class TestProject(test_identity.TestIdentityv2):
def setUp(self):
super(TestProject, self).setUp()
@ -50,9 +50,9 @@ class TestProjectCreate(TestProject):
identity_fakes.project_name,
]
verifylist = [
('project_name', identity_fakes.project_name),
('enable', False),
('disable', False),
('name', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -85,8 +85,8 @@ class TestProjectCreate(TestProject):
identity_fakes.project_name,
]
verifylist = [
('project_name', identity_fakes.project_name),
('description', 'new desc'),
('name', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -119,9 +119,9 @@ class TestProjectCreate(TestProject):
identity_fakes.project_name,
]
verifylist = [
('project_name', identity_fakes.project_name),
('enable', True),
('disable', False),
('name', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -154,9 +154,9 @@ class TestProjectCreate(TestProject):
identity_fakes.project_name,
]
verifylist = [
('project_name', identity_fakes.project_name),
('enable', False),
('disable', True),
('name', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -284,6 +284,11 @@ class TestProjectSet(TestProject):
copy.deepcopy(identity_fakes.PROJECT),
loaded=True,
)
self.projects_mock.update.return_value = fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.PROJECT),
loaded=True,
)
# Get the command object to test
self.cmd = project.SetProject(self.app, None)
@ -302,17 +307,6 @@ class TestProjectSet(TestProject):
result = self.cmd.run(parsed_args)
self.assertEqual(result, 0)
# Set expected values
kwargs = {
'description': identity_fakes.project_description,
'enabled': True,
'tenant_name': identity_fakes.project_name,
}
self.projects_mock.update.assert_called_with(
identity_fakes.project_id,
**kwargs
)
def test_project_set_name(self):
arglist = [
'--name', 'qwerty',
@ -320,6 +314,9 @@ class TestProjectSet(TestProject):
]
verifylist = [
('name', 'qwerty'),
('enable', False),
('disable', False),
('project', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -344,6 +341,9 @@ class TestProjectSet(TestProject):
]
verifylist = [
('description', 'new desc'),
('enable', False),
('disable', False),
('project', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -369,6 +369,7 @@ class TestProjectSet(TestProject):
verifylist = [
('enable', True),
('disable', False),
('project', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -394,6 +395,7 @@ class TestProjectSet(TestProject):
verifylist = [
('enable', False),
('disable', True),
('project', identity_fakes.project_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)

View File

@ -19,11 +19,11 @@ import mock
from openstackclient.common import exceptions
from openstackclient.identity.v2_0 import role
from openstackclient.tests import fakes
from openstackclient.tests.identity import fakes as identity_fakes
from openstackclient.tests.identity import test_identity
from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
from openstackclient.tests.identity.v2_0 import test_identity
class TestRole(test_identity.TestIdentity):
class TestRole(test_identity.TestIdentityv2):
def setUp(self):
super(TestRole, self).setUp()

View File

@ -17,11 +17,11 @@ import copy
from openstackclient.identity.v2_0 import service
from openstackclient.tests import fakes
from openstackclient.tests.identity import fakes as identity_fakes
from openstackclient.tests.identity import test_identity
from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
from openstackclient.tests.identity.v2_0 import test_identity
class TestService(test_identity.TestIdentity):
class TestService(test_identity.TestIdentityv2):
def setUp(self):
super(TestService, self).setUp()
@ -45,13 +45,14 @@ class TestServiceCreate(TestService):
# Get the command object to test
self.cmd = service.CreateService(self.app, None)
def test_service_create_minimum_options(self):
def test_service_create_name_type(self):
arglist = [
'--type', identity_fakes.service_type,
identity_fakes.service_name,
]
verifylist = [
('type', identity_fakes.service_type),
('description', None),
('name', identity_fakes.service_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -138,7 +139,7 @@ class TestServiceDelete(TestService):
self.cmd.take_action(parsed_args)
self.services_mock.delete.assert_called_with(
identity_fakes.service_name,
identity_fakes.service_id,
)

View File

@ -17,11 +17,11 @@ import copy
from openstackclient.identity.v2_0 import user
from openstackclient.tests import fakes
from openstackclient.tests.identity import fakes as identity_fakes
from openstackclient.tests.identity import test_identity
from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
from openstackclient.tests.identity.v2_0 import test_identity
class TestUser(test_identity.TestIdentity):
class TestUser(test_identity.TestIdentityv2):
def setUp(self):
super(TestUser, self).setUp()
@ -29,6 +29,7 @@ class TestUser(test_identity.TestIdentity):
# Get a shortcut to the TenantManager Mock
self.projects_mock = self.app.client_manager.identity.tenants
self.projects_mock.reset_mock()
# Get a shortcut to the UserManager Mock
self.users_mock = self.app.client_manager.identity.users
self.users_mock.reset_mock()
@ -44,6 +45,7 @@ class TestUserCreate(TestUser):
copy.deepcopy(identity_fakes.PROJECT),
loaded=True,
)
self.users_mock.create.return_value = fakes.FakeResource(
None,
copy.deepcopy(identity_fakes.USER),
@ -58,6 +60,8 @@ class TestUserCreate(TestUser):
identity_fakes.user_name,
]
verifylist = [
('enable', False),
('disable', False),
('name', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -70,7 +74,7 @@ class TestUserCreate(TestUser):
'enabled': True,
'tenant_id': None,
}
# users.create(name, password, email, tenant_id=None, enabled=True)
# UserManager.create(name, password, email, tenant_id=, enabled=)
self.users_mock.create.assert_called_with(
identity_fakes.user_name,
None,
@ -108,7 +112,7 @@ class TestUserCreate(TestUser):
'enabled': True,
'tenant_id': None,
}
# users.create(name, password, email, tenant_id=None, enabled=True)
# UserManager.create(name, password, email, tenant_id=, enabled=)
self.users_mock.create.assert_called_with(
identity_fakes.user_name,
'secret',
@ -146,7 +150,7 @@ class TestUserCreate(TestUser):
'enabled': True,
'tenant_id': None,
}
# users.create(name, password, email, tenant_id=None, enabled=True)
# UserManager.create(name, password, email, tenant_id=, enabled=)
self.users_mock.create.assert_called_with(
identity_fakes.user_name,
None,
@ -199,7 +203,7 @@ class TestUserCreate(TestUser):
'enabled': True,
'tenant_id': identity_fakes.PROJECT_2['id'],
}
# users.create(name, password, email, tenant_id=None, enabled=True)
# UserManager.create(name, password, email, tenant_id=, enabled=)
self.users_mock.create.assert_called_with(
identity_fakes.user_name,
None,
@ -238,7 +242,7 @@ class TestUserCreate(TestUser):
'enabled': True,
'tenant_id': None,
}
# users.create(name, password, email, tenant_id=None, enabled=True)
# UserManager.create(name, password, email, tenant_id=, enabled=)
self.users_mock.create.assert_called_with(
identity_fakes.user_name,
None,
@ -277,7 +281,7 @@ class TestUserCreate(TestUser):
'enabled': False,
'tenant_id': None,
}
# users.create(name, password, email, tenant_id=None, enabled=True)
# UserManager.create(name, password, email, tenant_id=, enabled=)
self.users_mock.create.assert_called_with(
identity_fakes.user_name,
None,
@ -342,6 +346,7 @@ class TestUserList(TestUser):
loaded=True,
),
]
self.users_mock.list.return_value = [
fakes.FakeResource(
None,
@ -443,18 +448,18 @@ class TestUserSet(TestUser):
identity_fakes.user_name,
]
verifylist = [
('user', identity_fakes.user_name),
('name', None),
('password', None),
('email', None),
('project', None),
('enable', False),
('disable', False),
('project', None),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
# SetUser doesn't call anything if no args are passed
self.assertFalse(self.users_mock.update.called)
result = self.cmd.run(parsed_args)
self.assertEqual(result, 0)
def test_user_set_name(self):
arglist = [
@ -463,6 +468,12 @@ class TestUserSet(TestUser):
]
verifylist = [
('name', 'qwerty'),
('password', None),
('email', None),
('project', None),
('enable', False),
('disable', False),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -471,8 +482,10 @@ class TestUserSet(TestUser):
# Set expected values
kwargs = {
'enabled': True,
'name': 'qwerty',
}
# UserManager.update(user, **kwargs)
self.users_mock.update.assert_called_with(
identity_fakes.user_id,
**kwargs
@ -484,13 +497,20 @@ class TestUserSet(TestUser):
identity_fakes.user_name,
]
verifylist = [
('name', None),
('password', 'secret'),
('email', None),
('project', None),
('enable', False),
('disable', False),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
# UserManager.update_password(user, password)
self.users_mock.update_password.assert_called_with(
identity_fakes.user_id,
'secret',
@ -502,7 +522,13 @@ class TestUserSet(TestUser):
identity_fakes.user_name,
]
verifylist = [
('name', None),
('password', None),
('email', 'barney@example.com'),
('project', None),
('enable', False),
('disable', False),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -512,7 +538,9 @@ class TestUserSet(TestUser):
# Set expected values
kwargs = {
'email': 'barney@example.com',
'enabled': True,
}
# UserManager.update(user, **kwargs)
self.users_mock.update.assert_called_with(
identity_fakes.user_id,
**kwargs
@ -524,13 +552,20 @@ class TestUserSet(TestUser):
identity_fakes.user_name,
]
verifylist = [
('name', None),
('password', None),
('email', None),
('project', identity_fakes.project_id),
('enable', False),
('disable', False),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
# UserManager.update_tenant(user, tenant)
self.users_mock.update_tenant.assert_called_with(
identity_fakes.user_id,
identity_fakes.project_id,
@ -542,8 +577,13 @@ class TestUserSet(TestUser):
identity_fakes.user_name,
]
verifylist = [
('name', None),
('password', None),
('email', None),
('project', None),
('enable', True),
('disable', False),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -554,6 +594,7 @@ class TestUserSet(TestUser):
kwargs = {
'enabled': True,
}
# UserManager.update(user, **kwargs)
self.users_mock.update.assert_called_with(
identity_fakes.user_id,
**kwargs
@ -565,8 +606,13 @@ class TestUserSet(TestUser):
identity_fakes.user_name,
]
verifylist = [
('name', None),
('password', None),
('email', None),
('project', None),
('enable', False),
('disable', True),
('user', identity_fakes.user_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -577,6 +623,7 @@ class TestUserSet(TestUser):
kwargs = {
'enabled': False,
}
# UserManager.update(user, **kwargs)
self.users_mock.update.assert_called_with(
identity_fakes.user_id,
**kwargs

View File

@ -70,6 +70,7 @@ class TestCommand(TestCase):
# Build up a fake app
self.fake_stdout = fakes.FakeStdout()
self.app = fakes.FakeApp(self.fake_stdout)
self.app.client_manager = fakes.FakeClientManager()
def check_parser(self, cmd, args, verify_args):
cmd_parser = cmd.get_parser('check_parser')