Merge "Fixed a bunch of spacing"
This commit is contained in:
commit
6176e802b3
@ -37,6 +37,7 @@ USER_AGENT = 'python-openstackclient'
|
||||
|
||||
class ClientCache(object):
|
||||
"""Descriptor class for caching created client handles."""
|
||||
|
||||
def __init__(self, factory):
|
||||
self.factory = factory
|
||||
self._handle = None
|
||||
|
@ -22,6 +22,7 @@ import six
|
||||
|
||||
|
||||
class CommandMeta(abc.ABCMeta):
|
||||
|
||||
def __new__(mcs, name, bases, cls_dict):
|
||||
if 'log' not in cls_dict:
|
||||
cls_dict['log'] = logging.getLogger(
|
||||
|
@ -41,6 +41,7 @@ class UnsupportedVersion(Exception):
|
||||
|
||||
class ClientException(Exception):
|
||||
"""The base exception class for all exceptions this library raises."""
|
||||
|
||||
def __init__(self, code, message=None, details=None):
|
||||
self.code = code
|
||||
self.message = message or self.__class__.message
|
||||
|
@ -169,7 +169,7 @@ class ShowQuota(command.ShowOne):
|
||||
project = utils.find_resource(
|
||||
identity_client.projects,
|
||||
parsed_args.project,
|
||||
).id
|
||||
).id
|
||||
|
||||
try:
|
||||
if parsed_args.quota_class:
|
||||
@ -193,7 +193,7 @@ class ShowQuota(command.ShowOne):
|
||||
project = utils.find_resource(
|
||||
identity_client.projects,
|
||||
parsed_args.project,
|
||||
).id
|
||||
).id
|
||||
return self.app.client_manager.network.get_quota(project)
|
||||
else:
|
||||
return {}
|
||||
|
@ -149,20 +149,20 @@ class ListFlavor(command.Lister):
|
||||
action="store_true",
|
||||
default=True,
|
||||
help="List only public flavors (default)",
|
||||
)
|
||||
)
|
||||
public_group.add_argument(
|
||||
"--private",
|
||||
dest="public",
|
||||
action="store_false",
|
||||
help="List only private flavors",
|
||||
)
|
||||
)
|
||||
public_group.add_argument(
|
||||
"--all",
|
||||
dest="all",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="List all flavors, whether public or private",
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'--long',
|
||||
action='store_true',
|
||||
|
@ -53,7 +53,7 @@ def make_client(instance):
|
||||
session=instance.session,
|
||||
region_name=instance._region_name,
|
||||
**kwargs
|
||||
)
|
||||
)
|
||||
|
||||
return client
|
||||
|
||||
@ -72,6 +72,7 @@ def build_option_parser(parser):
|
||||
|
||||
class IdentityClientv2(identity_client_v2.Client):
|
||||
"""Tweak the earlier client class to deal with some changes"""
|
||||
|
||||
def __getattr__(self, name):
|
||||
# Map v3 'projects' back to v2 'tenants'
|
||||
if name == "projects":
|
||||
|
@ -134,7 +134,7 @@ class ListRoleAssignment(command.Lister):
|
||||
if 'project' in scope:
|
||||
if include_names:
|
||||
prj = '@'.join([scope['project']['name'],
|
||||
scope['project']['domain']['name']])
|
||||
scope['project']['domain']['name']])
|
||||
setattr(assignment, 'project', prj)
|
||||
else:
|
||||
setattr(assignment, 'project', scope['project']['id'])
|
||||
|
@ -27,6 +27,7 @@ UNSCOPED_AUTH_PLUGINS = ['v3unscopedsaml', 'v3unscopedadfs', 'v3oidc']
|
||||
|
||||
def auth_with_unscoped_saml(func):
|
||||
"""Check the unscoped federated context"""
|
||||
|
||||
def _decorated(self, parsed_args):
|
||||
auth_plugin_name = self.app.client_manager.auth_plugin_name
|
||||
if auth_plugin_name in UNSCOPED_AUTH_PLUGINS:
|
||||
|
@ -265,8 +265,8 @@ class CreateImage(command.ShowOne):
|
||||
finally:
|
||||
# Clean up open files - make sure data isn't a string
|
||||
if ('data' in kwargs and hasattr(kwargs['data'], 'close') and
|
||||
kwargs['data'] != sys.stdin):
|
||||
kwargs['data'].close()
|
||||
kwargs['data'] != sys.stdin):
|
||||
kwargs['data'].close()
|
||||
|
||||
info.update(image._info)
|
||||
info['properties'] = utils.format_dict(info.get('properties', {}))
|
||||
@ -697,8 +697,8 @@ class SetImage(command.Command):
|
||||
finally:
|
||||
# Clean up open files - make sure data isn't a string
|
||||
if ('data' in kwargs and hasattr(kwargs['data'], 'close') and
|
||||
kwargs['data'] != sys.stdin):
|
||||
kwargs['data'].close()
|
||||
kwargs['data'] != sys.stdin):
|
||||
kwargs['data'].close()
|
||||
|
||||
|
||||
class ShowImage(command.ShowOne):
|
||||
|
@ -26,9 +26,9 @@ _formatters = {
|
||||
'allowed_address_pairs': utils.format_list_of_dicts,
|
||||
'binding_profile': utils.format_dict,
|
||||
'binding_vif_details': utils.format_dict,
|
||||
'dns_assignment': utils.format_list_of_dicts,
|
||||
'dns_assignment': utils.format_list_of_dicts,
|
||||
'extra_dhcp_opts': utils.format_list_of_dicts,
|
||||
'fixed_ips': utils.format_list_of_dicts,
|
||||
'fixed_ips': utils.format_list_of_dicts,
|
||||
'security_groups': utils.format_list,
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ class Container(object):
|
||||
|
||||
|
||||
class FakeOptions(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for option in auth.OPTIONS_LIST:
|
||||
setattr(self, option.replace('-', '_'), None)
|
||||
@ -71,6 +72,7 @@ class TestClientCache(utils.TestCase):
|
||||
|
||||
|
||||
class TestClientManager(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestClientManager, self).setUp()
|
||||
self.mock = mock.Mock()
|
||||
|
@ -19,6 +19,7 @@ from openstackclient.tests import utils as test_utils
|
||||
|
||||
|
||||
class FakeCommand(command.Command):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
pass
|
||||
|
||||
|
@ -20,6 +20,7 @@ from openstackclient.tests import utils
|
||||
|
||||
|
||||
class FakeCommand(object):
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
return cls
|
||||
@ -48,6 +49,7 @@ class FakeCommandManager(commandmanager.CommandManager):
|
||||
|
||||
|
||||
class TestCommandManager(utils.TestCase):
|
||||
|
||||
def test_add_command_group(self):
|
||||
mgr = FakeCommandManager('test')
|
||||
|
||||
|
@ -66,6 +66,7 @@ class TestContext(utils.TestCase):
|
||||
|
||||
|
||||
class TestFileFormatter(utils.TestCase):
|
||||
|
||||
def test_nothing(self):
|
||||
formatter = logs._FileFormatter()
|
||||
self.assertEqual(('%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
|
||||
@ -93,6 +94,7 @@ class TestFileFormatter(utils.TestCase):
|
||||
|
||||
|
||||
class TestLogConfigurator(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestLogConfigurator, self).setUp()
|
||||
self.options = mock.Mock()
|
||||
|
@ -75,7 +75,7 @@ class TestTiming(utils.TestCommand):
|
||||
def test_timing_list(self):
|
||||
self.app.timing_data = [(
|
||||
timing_url,
|
||||
datetime.timedelta(microseconds=timing_elapsed*1000000),
|
||||
datetime.timedelta(microseconds=timing_elapsed * 1000000),
|
||||
)]
|
||||
|
||||
arglist = []
|
||||
|
@ -250,6 +250,7 @@ class NoUniqueMatch(Exception):
|
||||
|
||||
|
||||
class TestFindResource(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestFindResource, self).setUp()
|
||||
self.name = 'legos'
|
||||
|
@ -87,6 +87,7 @@ SERVICE = {
|
||||
|
||||
|
||||
class FakeComputev2Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.aggregates = mock.Mock()
|
||||
self.aggregates.resource_class = fakes.FakeResource(None, {})
|
||||
@ -142,6 +143,7 @@ class FakeComputev2Client(object):
|
||||
|
||||
|
||||
class TestComputev2(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestComputev2, self).setUp()
|
||||
|
||||
|
@ -51,6 +51,7 @@ TEST_VERSIONS = fixture.DiscoveryList(href=AUTH_URL)
|
||||
|
||||
|
||||
class FakeStdout(object):
|
||||
|
||||
def __init__(self):
|
||||
self.content = []
|
||||
|
||||
@ -65,6 +66,7 @@ class FakeStdout(object):
|
||||
|
||||
|
||||
class FakeLog(object):
|
||||
|
||||
def __init__(self):
|
||||
self.messages = {}
|
||||
|
||||
@ -85,6 +87,7 @@ class FakeLog(object):
|
||||
|
||||
|
||||
class FakeApp(object):
|
||||
|
||||
def __init__(self, _stdout, _log):
|
||||
self.stdout = _stdout
|
||||
self.client_manager = None
|
||||
@ -95,12 +98,14 @@ class FakeApp(object):
|
||||
|
||||
|
||||
class FakeClient(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.endpoint = kwargs['endpoint']
|
||||
self.token = kwargs['token']
|
||||
|
||||
|
||||
class FakeClientManager(object):
|
||||
|
||||
def __init__(self):
|
||||
self.compute = None
|
||||
self.identity = None
|
||||
@ -129,12 +134,14 @@ class FakeClientManager(object):
|
||||
|
||||
|
||||
class FakeModule(object):
|
||||
|
||||
def __init__(self, name, version):
|
||||
self.name = name
|
||||
self.__version__ = version
|
||||
|
||||
|
||||
class FakeResource(object):
|
||||
|
||||
def __init__(self, manager=None, info={}, loaded=False, methods={}):
|
||||
"""Set attributes and methods for a resource.
|
||||
|
||||
@ -178,6 +185,7 @@ class FakeResource(object):
|
||||
|
||||
|
||||
class FakeResponse(requests.Response):
|
||||
|
||||
def __init__(self, headers={}, status_code=200, data=None, encoding=None):
|
||||
super(FakeResponse, self).__init__()
|
||||
|
||||
@ -190,6 +198,7 @@ class FakeResponse(requests.Response):
|
||||
|
||||
|
||||
class FakeModel(dict):
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self[key]
|
||||
|
@ -128,6 +128,7 @@ EXTENSION = {
|
||||
|
||||
|
||||
class FakeIdentityv2Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.roles = mock.Mock()
|
||||
self.roles.resource_class = fakes.FakeResource(None, {})
|
||||
@ -157,6 +158,7 @@ class FakeIdentityv2Client(object):
|
||||
|
||||
|
||||
class TestIdentityv2(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIdentityv2, self).setUp()
|
||||
|
||||
|
@ -420,6 +420,7 @@ OAUTH_VERIFIER = {
|
||||
|
||||
|
||||
class FakeAuth(object):
|
||||
|
||||
def __init__(self, auth_method_class=None):
|
||||
self._auth_method_class = auth_method_class
|
||||
|
||||
@ -428,11 +429,13 @@ class FakeAuth(object):
|
||||
|
||||
|
||||
class FakeSession(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.auth = FakeAuth()
|
||||
|
||||
|
||||
class FakeIdentityv3Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.domains = mock.Mock()
|
||||
self.domains.resource_class = fakes.FakeResource(None, {})
|
||||
@ -468,6 +471,7 @@ class FakeIdentityv3Client(object):
|
||||
|
||||
|
||||
class FakeFederationManager(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.identity_providers = mock.Mock()
|
||||
self.identity_providers.resource_class = fakes.FakeResource(None, {})
|
||||
@ -484,12 +488,14 @@ class FakeFederationManager(object):
|
||||
|
||||
|
||||
class FakeFederatedClient(FakeIdentityv3Client):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(FakeFederatedClient, self).__init__(**kwargs)
|
||||
self.federation = FakeFederationManager()
|
||||
|
||||
|
||||
class FakeOAuth1Client(FakeIdentityv3Client):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(FakeOAuth1Client, self).__init__(**kwargs)
|
||||
|
||||
@ -502,6 +508,7 @@ class FakeOAuth1Client(FakeIdentityv3Client):
|
||||
|
||||
|
||||
class TestIdentityv3(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIdentityv3, self).setUp()
|
||||
|
||||
@ -512,6 +519,7 @@ class TestIdentityv3(utils.TestCommand):
|
||||
|
||||
|
||||
class TestFederatedIdentity(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestFederatedIdentity, self).setUp()
|
||||
|
||||
@ -522,6 +530,7 @@ class TestFederatedIdentity(utils.TestCommand):
|
||||
|
||||
|
||||
class TestOAuth1(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOAuth1, self).setUp()
|
||||
|
||||
|
@ -46,6 +46,7 @@ class TestCredential(identity_fakes.TestIdentityv3):
|
||||
|
||||
|
||||
class TestCredentialSet(TestCredential):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCredentialSet, self).setUp()
|
||||
self.cmd = credential.SetCredential(self.app, None)
|
||||
|
@ -368,6 +368,7 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
def test_identity_provider_set_description(self):
|
||||
"""Set Identity Provider's description. """
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
updated_idp = copy.deepcopy(identity_fakes.IDENTITY_PROVIDER)
|
||||
@ -412,6 +413,7 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
Set Identity Provider's ``enabled`` attribute to False.
|
||||
"""
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
updated_idp = copy.deepcopy(identity_fakes.IDENTITY_PROVIDER)
|
||||
@ -459,6 +461,7 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
Set Identity Provider's ``enabled`` attribute to True.
|
||||
"""
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
resources = fakes.FakeResource(
|
||||
@ -495,6 +498,7 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
Set Identity Provider's ``enabled`` attribute to True.
|
||||
"""
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
self.new_remote_id = 'new_entity'
|
||||
@ -540,6 +544,7 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
Set Identity Provider's ``enabled`` attribute to True.
|
||||
"""
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
self.new_remote_id = 'new_entity'
|
||||
|
@ -33,71 +33,74 @@ class TestMapping(identity_fakes.TestFederatedIdentity):
|
||||
|
||||
|
||||
class TestMappingCreate(TestMapping):
|
||||
def setUp(self):
|
||||
super(TestMappingCreate, self).setUp()
|
||||
self.mapping_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.MAPPING_RESPONSE),
|
||||
loaded=True
|
||||
)
|
||||
self.cmd = mapping.CreateMapping(self.app, None)
|
||||
|
||||
def test_create_mapping(self):
|
||||
arglist = [
|
||||
'--rules', identity_fakes.mapping_rules_file_path,
|
||||
identity_fakes.mapping_id
|
||||
]
|
||||
verifylist = [
|
||||
('mapping', identity_fakes.mapping_id),
|
||||
('rules', identity_fakes.mapping_rules_file_path)
|
||||
]
|
||||
def setUp(self):
|
||||
super(TestMappingCreate, self).setUp()
|
||||
self.mapping_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.MAPPING_RESPONSE),
|
||||
loaded=True
|
||||
)
|
||||
self.cmd = mapping.CreateMapping(self.app, None)
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
def test_create_mapping(self):
|
||||
arglist = [
|
||||
'--rules', identity_fakes.mapping_rules_file_path,
|
||||
identity_fakes.mapping_id
|
||||
]
|
||||
verifylist = [
|
||||
('mapping', identity_fakes.mapping_id),
|
||||
('rules', identity_fakes.mapping_rules_file_path)
|
||||
]
|
||||
|
||||
mocker = mock.Mock()
|
||||
mocker.return_value = identity_fakes.MAPPING_RULES
|
||||
with mock.patch("openstackclient.identity.v3.mapping."
|
||||
"CreateMapping._read_rules", mocker):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.mapping_mock.create.assert_called_with(
|
||||
mapping_id=identity_fakes.mapping_id,
|
||||
rules=identity_fakes.MAPPING_RULES)
|
||||
mocker = mock.Mock()
|
||||
mocker.return_value = identity_fakes.MAPPING_RULES
|
||||
with mock.patch("openstackclient.identity.v3.mapping."
|
||||
"CreateMapping._read_rules", mocker):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
collist = ('id', 'rules')
|
||||
self.assertEqual(collist, columns)
|
||||
self.mapping_mock.create.assert_called_with(
|
||||
mapping_id=identity_fakes.mapping_id,
|
||||
rules=identity_fakes.MAPPING_RULES)
|
||||
|
||||
datalist = (identity_fakes.mapping_id,
|
||||
identity_fakes.MAPPING_RULES)
|
||||
self.assertEqual(datalist, data)
|
||||
collist = ('id', 'rules')
|
||||
self.assertEqual(collist, columns)
|
||||
|
||||
datalist = (identity_fakes.mapping_id,
|
||||
identity_fakes.MAPPING_RULES)
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
|
||||
class TestMappingDelete(TestMapping):
|
||||
def setUp(self):
|
||||
super(TestMappingDelete, self).setUp()
|
||||
self.mapping_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.MAPPING_RESPONSE),
|
||||
loaded=True)
|
||||
|
||||
self.mapping_mock.delete.return_value = None
|
||||
self.cmd = mapping.DeleteMapping(self.app, None)
|
||||
def setUp(self):
|
||||
super(TestMappingDelete, self).setUp()
|
||||
self.mapping_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.MAPPING_RESPONSE),
|
||||
loaded=True)
|
||||
|
||||
def test_delete_mapping(self):
|
||||
arglist = [
|
||||
identity_fakes.mapping_id
|
||||
]
|
||||
verifylist = [
|
||||
('mapping', identity_fakes.mapping_id)
|
||||
]
|
||||
self.mapping_mock.delete.return_value = None
|
||||
self.cmd = mapping.DeleteMapping(self.app, None)
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.mapping_mock.delete.assert_called_with(
|
||||
identity_fakes.mapping_id)
|
||||
def test_delete_mapping(self):
|
||||
arglist = [
|
||||
identity_fakes.mapping_id
|
||||
]
|
||||
verifylist = [
|
||||
('mapping', identity_fakes.mapping_id)
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.mapping_mock.delete.assert_called_with(
|
||||
identity_fakes.mapping_id)
|
||||
|
||||
|
||||
class TestMappingList(TestMapping):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMappingList, self).setUp()
|
||||
self.mapping_mock.get.return_value = fakes.FakeResource(
|
||||
@ -141,6 +144,7 @@ class TestMappingList(TestMapping):
|
||||
|
||||
|
||||
class TestMappingShow(TestMapping):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMappingShow, self).setUp()
|
||||
|
||||
|
@ -557,7 +557,7 @@ class TestRoleAssignmentList(TestRoleAssignment):
|
||||
'@'.join([identity_fakes.user_name, identity_fakes.domain_name]),
|
||||
'',
|
||||
'@'.join([identity_fakes.project_name,
|
||||
identity_fakes.domain_name]),
|
||||
identity_fakes.domain_name]),
|
||||
'',
|
||||
False
|
||||
), (identity_fakes.role_name,
|
||||
|
@ -305,6 +305,7 @@ class TestServiceProviderSet(TestServiceProvider):
|
||||
|
||||
Set Service Provider's ``enabled`` attribute to False.
|
||||
"""
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
updated_sp = copy.deepcopy(service_fakes.SERVICE_PROVIDER)
|
||||
@ -343,6 +344,7 @@ class TestServiceProviderSet(TestServiceProvider):
|
||||
|
||||
Set Service Provider's ``enabled`` attribute to True.
|
||||
"""
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
resources = fakes.FakeResource(
|
||||
|
@ -53,6 +53,7 @@ IMAGE_data = tuple((IMAGE_output[x] for x in sorted(IMAGE_output)))
|
||||
|
||||
|
||||
class FakeImagev1Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.images = mock.Mock()
|
||||
self.images.resource_class = fakes.FakeResource(None, {})
|
||||
@ -61,6 +62,7 @@ class FakeImagev1Client(object):
|
||||
|
||||
|
||||
class TestImagev1(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestImagev1, self).setUp()
|
||||
|
||||
|
@ -148,6 +148,7 @@ IMAGE_schema = {
|
||||
|
||||
|
||||
class FakeImagev2Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.images = mock.Mock()
|
||||
self.images.resource_class = fakes.FakeResource(None, {})
|
||||
@ -158,6 +159,7 @@ class FakeImagev2Client(object):
|
||||
|
||||
|
||||
class TestImagev2(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestImagev2, self).setUp()
|
||||
|
||||
|
@ -381,7 +381,7 @@ class TestAddProjectToImage(TestImage):
|
||||
arglist = [
|
||||
image_fakes.image_id,
|
||||
identity_fakes.project_id,
|
||||
]
|
||||
]
|
||||
verifylist = [
|
||||
('image', image_fakes.image_id),
|
||||
('project', identity_fakes.project_id),
|
||||
|
@ -46,6 +46,7 @@ def _add_compute_argument(parser):
|
||||
|
||||
|
||||
class FakeNetworkAndComputeCommand(common.NetworkAndComputeCommand):
|
||||
|
||||
def update_parser_common(self, parser):
|
||||
return _add_common_argument(parser)
|
||||
|
||||
@ -63,6 +64,7 @@ class FakeNetworkAndComputeCommand(common.NetworkAndComputeCommand):
|
||||
|
||||
|
||||
class FakeNetworkAndComputeLister(common.NetworkAndComputeLister):
|
||||
|
||||
def update_parser_common(self, parser):
|
||||
return _add_common_argument(parser)
|
||||
|
||||
@ -80,6 +82,7 @@ class FakeNetworkAndComputeLister(common.NetworkAndComputeLister):
|
||||
|
||||
|
||||
class FakeNetworkAndComputeShowOne(common.NetworkAndComputeShowOne):
|
||||
|
||||
def update_parser_common(self, parser):
|
||||
return _add_common_argument(parser)
|
||||
|
||||
@ -97,6 +100,7 @@ class FakeNetworkAndComputeShowOne(common.NetworkAndComputeShowOne):
|
||||
|
||||
|
||||
class TestNetworkAndCompute(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNetworkAndCompute, self).setUp()
|
||||
|
||||
@ -150,18 +154,21 @@ class TestNetworkAndCompute(utils.TestCommand):
|
||||
|
||||
|
||||
class TestNetworkAndComputeCommand(TestNetworkAndCompute):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNetworkAndComputeCommand, self).setUp()
|
||||
self.cmd = FakeNetworkAndComputeCommand(self.app, self.namespace)
|
||||
|
||||
|
||||
class TestNetworkAndComputeLister(TestNetworkAndCompute):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNetworkAndComputeLister, self).setUp()
|
||||
self.cmd = FakeNetworkAndComputeLister(self.app, self.namespace)
|
||||
|
||||
|
||||
class TestNetworkAndComputeShowOne(TestNetworkAndCompute):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNetworkAndComputeShowOne, self).setUp()
|
||||
self.cmd = FakeNetworkAndComputeShowOne(self.app, self.namespace)
|
||||
|
@ -51,11 +51,13 @@ def create_extension():
|
||||
|
||||
|
||||
class FakeNetworkV2Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.extensions = mock.Mock(return_value=[create_extension()])
|
||||
|
||||
|
||||
class TestNetworkV2(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNetworkV2, self).setUp()
|
||||
|
||||
|
@ -20,6 +20,7 @@ from openstackclient.tests import utils as tests_utils
|
||||
|
||||
|
||||
class TestSubnet(network_fakes.TestNetworkV2):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSubnet, self).setUp()
|
||||
|
||||
|
@ -20,6 +20,7 @@ from openstackclient.tests import utils as tests_utils
|
||||
|
||||
|
||||
class TestSubnetPool(network_fakes.TestNetworkV2):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSubnetPool, self).setUp()
|
||||
|
||||
|
@ -76,6 +76,7 @@ OBJECT_2 = {
|
||||
|
||||
|
||||
class TestObjectv1(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectv1, self).setUp()
|
||||
|
||||
|
@ -26,6 +26,7 @@ AUTH_URL = "http://0.0.0.0"
|
||||
|
||||
|
||||
class FakeClient(object):
|
||||
|
||||
def __init__(self, endpoint=None, **kwargs):
|
||||
self.endpoint = AUTH_URL
|
||||
self.token = AUTH_TOKEN
|
||||
|
@ -26,6 +26,7 @@ AUTH_URL = "http://0.0.0.0"
|
||||
|
||||
|
||||
class TestObject(object_fakes.TestObjectv1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObject, self).setUp()
|
||||
self.app.client_manager.object_store = object_store.APIv1(
|
||||
|
@ -20,6 +20,7 @@ from openstackclient.tests.object.v1 import fakes as object_fakes
|
||||
|
||||
|
||||
class TestObjectAll(object_fakes.TestObjectv1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectAll, self).setUp()
|
||||
|
||||
|
@ -161,6 +161,7 @@ def fake_execute(shell, cmd):
|
||||
|
||||
|
||||
class TestShell(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShell, self).setUp()
|
||||
patch = "openstackclient.shell.OpenStackShell.run_subcommand"
|
||||
@ -280,6 +281,7 @@ class TestShell(utils.TestCase):
|
||||
|
||||
class TestShellHelp(TestShell):
|
||||
"""Test the deferred help flag"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellHelp, self).setUp()
|
||||
self.orig_env, os.environ = os.environ, {}
|
||||
@ -304,6 +306,7 @@ class TestShellHelp(TestShell):
|
||||
|
||||
|
||||
class TestShellOptions(TestShell):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellOptions, self).setUp()
|
||||
self.orig_env, os.environ = os.environ, {}
|
||||
@ -391,6 +394,7 @@ class TestShellOptions(TestShell):
|
||||
|
||||
|
||||
class TestShellTokenAuthEnv(TestShell):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellTokenAuthEnv, self).setUp()
|
||||
env = {
|
||||
@ -438,6 +442,7 @@ class TestShellTokenAuthEnv(TestShell):
|
||||
|
||||
|
||||
class TestShellTokenEndpointAuthEnv(TestShell):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellTokenEndpointAuthEnv, self).setUp()
|
||||
env = {
|
||||
@ -485,6 +490,7 @@ class TestShellTokenEndpointAuthEnv(TestShell):
|
||||
|
||||
|
||||
class TestShellCli(TestShell):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCli, self).setUp()
|
||||
env = {
|
||||
@ -706,6 +712,7 @@ class TestShellCli(TestShell):
|
||||
|
||||
|
||||
class TestShellCliEnv(TestShell):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliEnv, self).setUp()
|
||||
env = {
|
||||
|
@ -28,6 +28,7 @@ class ParserException(Exception):
|
||||
|
||||
|
||||
class TestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
testtools.TestCase.setUp(self)
|
||||
|
||||
|
@ -130,11 +130,13 @@ QOS_WITH_ASSOCIATIONS = {
|
||||
|
||||
|
||||
class FakeImagev1Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.images = mock.Mock()
|
||||
|
||||
|
||||
class FakeVolumev1Client(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.volumes = mock.Mock()
|
||||
self.volumes.resource_class = fakes.FakeResource(None, {})
|
||||
@ -151,6 +153,7 @@ class FakeVolumev1Client(object):
|
||||
|
||||
|
||||
class TestVolumev1(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumev1, self).setUp()
|
||||
|
||||
|
@ -34,6 +34,7 @@ class TestQos(volume_fakes.TestVolumev1):
|
||||
|
||||
|
||||
class TestQosAssociate(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosAssociate, self).setUp()
|
||||
|
||||
@ -183,6 +184,7 @@ class TestQosCreate(TestQos):
|
||||
|
||||
|
||||
class TestQosDelete(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosDelete, self).setUp()
|
||||
|
||||
@ -223,6 +225,7 @@ class TestQosDelete(TestQos):
|
||||
|
||||
|
||||
class TestQosDisassociate(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosDisassociate, self).setUp()
|
||||
|
||||
@ -277,6 +280,7 @@ class TestQosDisassociate(TestQos):
|
||||
|
||||
|
||||
class TestQosList(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosList, self).setUp()
|
||||
|
||||
@ -323,6 +327,7 @@ class TestQosList(TestQos):
|
||||
|
||||
|
||||
class TestQosSet(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosSet, self).setUp()
|
||||
|
||||
@ -354,6 +359,7 @@ class TestQosSet(TestQos):
|
||||
|
||||
|
||||
class TestQosShow(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosShow, self).setUp()
|
||||
|
||||
@ -405,6 +411,7 @@ class TestQosShow(TestQos):
|
||||
|
||||
|
||||
class TestQosUnset(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosUnset, self).setUp()
|
||||
|
||||
|
@ -213,6 +213,7 @@ IMAGE = {
|
||||
|
||||
|
||||
class FakeVolumeClient(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.volumes = mock.Mock()
|
||||
self.volumes.resource_class = fakes.FakeResource(None, {})
|
||||
@ -233,6 +234,7 @@ class FakeVolumeClient(object):
|
||||
|
||||
|
||||
class TestVolume(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolume, self).setUp()
|
||||
|
||||
|
@ -33,6 +33,7 @@ class TestBackup(volume_fakes.TestVolume):
|
||||
|
||||
|
||||
class TestBackupCreate(TestBackup):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBackupCreate, self).setUp()
|
||||
|
||||
@ -78,6 +79,7 @@ class TestBackupCreate(TestBackup):
|
||||
|
||||
|
||||
class TestBackupShow(TestBackup):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBackupShow, self).setUp()
|
||||
|
||||
@ -105,6 +107,7 @@ class TestBackupShow(TestBackup):
|
||||
|
||||
|
||||
class TestBackupDelete(TestBackup):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBackupDelete, self).setUp()
|
||||
|
||||
@ -132,6 +135,7 @@ class TestBackupDelete(TestBackup):
|
||||
|
||||
|
||||
class TestBackupRestore(TestBackup):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBackupRestore, self).setUp()
|
||||
|
||||
|
@ -34,6 +34,7 @@ class TestQos(volume_fakes.TestVolume):
|
||||
|
||||
|
||||
class TestQosAssociate(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosAssociate, self).setUp()
|
||||
|
||||
@ -184,6 +185,7 @@ class TestQosCreate(TestQos):
|
||||
|
||||
|
||||
class TestQosDelete(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosDelete, self).setUp()
|
||||
|
||||
@ -224,6 +226,7 @@ class TestQosDelete(TestQos):
|
||||
|
||||
|
||||
class TestQosDisassociate(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosDisassociate, self).setUp()
|
||||
|
||||
@ -278,6 +281,7 @@ class TestQosDisassociate(TestQos):
|
||||
|
||||
|
||||
class TestQosList(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosList, self).setUp()
|
||||
|
||||
@ -324,6 +328,7 @@ class TestQosList(TestQos):
|
||||
|
||||
|
||||
class TestQosSet(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosSet, self).setUp()
|
||||
|
||||
@ -355,6 +360,7 @@ class TestQosSet(TestQos):
|
||||
|
||||
|
||||
class TestQosShow(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosShow, self).setUp()
|
||||
|
||||
@ -406,6 +412,7 @@ class TestQosShow(TestQos):
|
||||
|
||||
|
||||
class TestQosUnset(TestQos):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQosUnset, self).setUp()
|
||||
|
||||
|
@ -31,6 +31,7 @@ class TestSnapshot(volume_fakes.TestVolume):
|
||||
|
||||
|
||||
class TestSnapshotCreate(TestSnapshot):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSnapshotCreate, self).setUp()
|
||||
|
||||
@ -76,6 +77,7 @@ class TestSnapshotCreate(TestSnapshot):
|
||||
|
||||
|
||||
class TestSnapshotShow(TestSnapshot):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSnapshotShow, self).setUp()
|
||||
|
||||
@ -103,6 +105,7 @@ class TestSnapshotShow(TestSnapshot):
|
||||
|
||||
|
||||
class TestSnapshotDelete(TestSnapshot):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSnapshotDelete, self).setUp()
|
||||
|
||||
@ -130,6 +133,7 @@ class TestSnapshotDelete(TestSnapshot):
|
||||
|
||||
|
||||
class TestSnapshotSet(TestSnapshot):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSnapshotSet, self).setUp()
|
||||
|
||||
@ -171,6 +175,7 @@ class TestSnapshotSet(TestSnapshot):
|
||||
|
||||
|
||||
class TestSnapshotUnset(TestSnapshot):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSnapshotUnset, self).setUp()
|
||||
|
||||
@ -247,7 +252,7 @@ class TestSnapshotList(TestSnapshot):
|
||||
volume_fakes.snapshot_description,
|
||||
"available",
|
||||
volume_fakes.snapshot_size
|
||||
),)
|
||||
),)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_snapshot_list_with_options(self):
|
||||
|
@ -147,7 +147,7 @@ class TestTypeList(TestType):
|
||||
datalist = ((
|
||||
volume_fakes.type_id,
|
||||
volume_fakes.type_name,
|
||||
),)
|
||||
),)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_type_list_with_options(self):
|
||||
@ -166,11 +166,12 @@ class TestTypeList(TestType):
|
||||
volume_fakes.type_name,
|
||||
volume_fakes.type_description,
|
||||
"foo='bar'"
|
||||
),)
|
||||
),)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
||||
class TestTypeShow(TestType):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTypeShow, self).setUp()
|
||||
|
||||
@ -314,6 +315,7 @@ class TestTypeUnset(TestType):
|
||||
|
||||
|
||||
class TestTypeDelete(TestType):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTypeDelete, self).setUp()
|
||||
|
||||
|
@ -24,6 +24,7 @@ from openstackclient.volume.v2 import volume
|
||||
|
||||
|
||||
class TestVolume(volume_fakes.TestVolume):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolume, self).setUp()
|
||||
|
||||
@ -377,6 +378,7 @@ class TestVolumeCreate(TestVolume):
|
||||
|
||||
|
||||
class TestVolumeDelete(TestVolume):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumeDelete, self).setUp()
|
||||
|
||||
@ -726,6 +728,7 @@ class TestVolumeList(TestVolume):
|
||||
|
||||
|
||||
class TestVolumeShow(TestVolume):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumeShow, self).setUp()
|
||||
|
||||
|
@ -267,7 +267,7 @@ class ListVolume(command.Lister):
|
||||
'Status',
|
||||
'Size',
|
||||
'Attachments',
|
||||
]
|
||||
]
|
||||
column_headers = copy.deepcopy(columns)
|
||||
column_headers[1] = 'Display Name'
|
||||
column_headers[4] = 'Attached to'
|
||||
|
Loading…
Reference in New Issue
Block a user