Blacken openstackclient.image
Black used with the '-l 79 -S' flags. A future change will ignore this commit in git-blame history by adding a 'git-blame-ignore-revs' file. Change-Id: I6420ec6fd550903b03083b9b1f8391511913c86f Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
329296cedd
commit
7ca43885c2
@ -32,7 +32,6 @@ API_VERSIONS = {
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
|
||||
LOG.debug(
|
||||
'Image client initialized using OpenStack SDK: %s',
|
||||
instance.sdk_connection.image,
|
||||
@ -46,7 +45,7 @@ def build_option_parser(parser):
|
||||
'--os-image-api-version',
|
||||
metavar='<image-api-version>',
|
||||
default=utils.env('OS_IMAGE_API_VERSION'),
|
||||
help=_('Image API version, default=%s (Env: OS_IMAGE_API_VERSION)') %
|
||||
DEFAULT_API_VERSION,
|
||||
help=_('Image API version, default=%s (Env: OS_IMAGE_API_VERSION)')
|
||||
% DEFAULT_API_VERSION,
|
||||
)
|
||||
return parser
|
||||
|
@ -39,29 +39,42 @@ else:
|
||||
CONTAINER_CHOICES = ["ami", "ari", "aki", "bare", "docker", "ova", "ovf"]
|
||||
DEFAULT_CONTAINER_FORMAT = 'bare'
|
||||
DEFAULT_DISK_FORMAT = 'raw'
|
||||
DISK_CHOICES = ["ami", "ari", "aki", "vhd", "vmdk", "raw", "qcow2", "vhdx",
|
||||
"vdi", "iso", "ploop"]
|
||||
DISK_CHOICES = [
|
||||
"ami",
|
||||
"ari",
|
||||
"aki",
|
||||
"vhd",
|
||||
"vmdk",
|
||||
"raw",
|
||||
"qcow2",
|
||||
"vhdx",
|
||||
"vdi",
|
||||
"iso",
|
||||
"ploop",
|
||||
]
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'is_protected': 'protected',
|
||||
'owner_id': 'owner'
|
||||
}
|
||||
column_map = {'is_protected': 'protected', 'owner_id': 'owner'}
|
||||
hidden_columns = [
|
||||
'location', 'checksum', 'copy_from', 'created_at', 'status',
|
||||
'location',
|
||||
'checksum',
|
||||
'copy_from',
|
||||
'created_at',
|
||||
'status',
|
||||
'updated_at',
|
||||
]
|
||||
return utils.get_osc_show_columns_for_sdk_resource(
|
||||
item.to_dict(), column_map, hidden_columns,
|
||||
item.to_dict(),
|
||||
column_map,
|
||||
hidden_columns,
|
||||
)
|
||||
|
||||
|
||||
_formatters = {
|
||||
}
|
||||
_formatters = {}
|
||||
|
||||
|
||||
class HumanReadableSizeColumn(cliff_columns.FormattableColumn):
|
||||
@ -117,25 +130,36 @@ class CreateImage(command.ShowOne):
|
||||
default=DEFAULT_CONTAINER_FORMAT,
|
||||
metavar="<container-format>",
|
||||
choices=CONTAINER_CHOICES,
|
||||
help=(_("Image container format. "
|
||||
help=(
|
||||
_(
|
||||
"Image container format. "
|
||||
"The supported options are: %(option_list)s. "
|
||||
"The default format is: %(default_opt)s") %
|
||||
{'option_list': ', '.join(CONTAINER_CHOICES),
|
||||
'default_opt': DEFAULT_CONTAINER_FORMAT})
|
||||
"The default format is: %(default_opt)s"
|
||||
)
|
||||
% {
|
||||
'option_list': ', '.join(CONTAINER_CHOICES),
|
||||
'default_opt': DEFAULT_CONTAINER_FORMAT,
|
||||
}
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--disk-format",
|
||||
default=DEFAULT_DISK_FORMAT,
|
||||
metavar="<disk-format>",
|
||||
choices=DISK_CHOICES,
|
||||
help=_("Image disk format. The supported options are: %s. "
|
||||
"The default format is: raw") % ', '.join(DISK_CHOICES)
|
||||
help=_(
|
||||
"Image disk format. The supported options are: %s. "
|
||||
"The default format is: raw"
|
||||
)
|
||||
% ', '.join(DISK_CHOICES),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--size",
|
||||
metavar="<size>",
|
||||
help=_("Image size, in bytes (only used with --location and"
|
||||
" --copy-from)"),
|
||||
help=_(
|
||||
"Image size, in bytes (only used with --location and"
|
||||
" --copy-from)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--min-disk",
|
||||
@ -175,8 +199,10 @@ class CreateImage(command.ShowOne):
|
||||
dest='force',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_("Force image creation if volume is in use "
|
||||
"(only meaningful with --volume)"),
|
||||
help=_(
|
||||
"Force image creation if volume is in use "
|
||||
"(only meaningful with --volume)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--checksum",
|
||||
@ -210,8 +236,10 @@ class CreateImage(command.ShowOne):
|
||||
dest="properties",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Set a property on this image "
|
||||
"(repeat option to set multiple properties)"),
|
||||
help=_(
|
||||
"Set a property on this image "
|
||||
"(repeat option to set multiple properties)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--project",
|
||||
@ -226,10 +254,23 @@ class CreateImage(command.ShowOne):
|
||||
# Build an attribute dict from the parsed args, only include
|
||||
# attributes that were actually set on the command line
|
||||
kwargs = {}
|
||||
copy_attrs = ('name', 'id', 'store', 'container_format',
|
||||
'disk_format', 'owner', 'size', 'min_disk', 'min_ram',
|
||||
'location', 'copy_from', 'volume', 'force',
|
||||
'checksum', 'properties')
|
||||
copy_attrs = (
|
||||
'name',
|
||||
'id',
|
||||
'store',
|
||||
'container_format',
|
||||
'disk_format',
|
||||
'owner',
|
||||
'size',
|
||||
'min_disk',
|
||||
'min_ram',
|
||||
'location',
|
||||
'copy_from',
|
||||
'volume',
|
||||
'force',
|
||||
'checksum',
|
||||
'properties',
|
||||
)
|
||||
for attr in copy_attrs:
|
||||
if attr in parsed_args:
|
||||
val = getattr(parsed_args, attr, None)
|
||||
@ -295,20 +336,25 @@ class CreateImage(command.ShowOne):
|
||||
image = image_client.create_image(**kwargs)
|
||||
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):
|
||||
if (
|
||||
'data' in kwargs
|
||||
and hasattr(kwargs['data'], 'close')
|
||||
and kwargs['data'] != sys.stdin
|
||||
):
|
||||
kwargs['data'].close()
|
||||
|
||||
if image:
|
||||
display_columns, columns = _get_columns(image)
|
||||
_formatters['properties'] = format_columns.DictColumn
|
||||
data = utils.get_item_properties(image, columns,
|
||||
formatters=_formatters)
|
||||
data = utils.get_item_properties(
|
||||
image, columns, formatters=_formatters
|
||||
)
|
||||
return (display_columns, data)
|
||||
elif info:
|
||||
info.update(image._info)
|
||||
info['properties'] = format_columns.DictColumn(
|
||||
info.get('properties', {}))
|
||||
info.get('properties', {})
|
||||
)
|
||||
return zip(*sorted(info.items()))
|
||||
|
||||
|
||||
@ -384,9 +430,11 @@ class ListImage(command.Lister):
|
||||
'--sort',
|
||||
metavar="<key>[:<direction>]",
|
||||
default='name:asc',
|
||||
help=_("Sort output by selected keys and directions(asc or desc) "
|
||||
"(default: name:asc), multiple keys and directions can be "
|
||||
"specified separated by comma"),
|
||||
help=_(
|
||||
"Sort output by selected keys and directions(asc or desc) "
|
||||
"(default: name:asc), multiple keys and directions can be "
|
||||
"specified separated by comma"
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -447,14 +495,17 @@ class ListImage(command.Lister):
|
||||
|
||||
return (
|
||||
column_headers,
|
||||
(utils.get_item_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters={
|
||||
'is_public': VisibilityColumn,
|
||||
'properties': format_columns.DictColumn,
|
||||
},
|
||||
) for s in data)
|
||||
(
|
||||
utils.get_item_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters={
|
||||
'is_public': VisibilityColumn,
|
||||
'properties': format_columns.DictColumn,
|
||||
},
|
||||
)
|
||||
for s in data
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@ -517,21 +568,21 @@ class SetImage(command.Command):
|
||||
"--container-format",
|
||||
metavar="<container-format>",
|
||||
choices=CONTAINER_CHOICES,
|
||||
help=_("Image container format. The supported options are: %s") %
|
||||
', '.join(CONTAINER_CHOICES)
|
||||
help=_("Image container format. The supported options are: %s")
|
||||
% ', '.join(CONTAINER_CHOICES),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--disk-format",
|
||||
metavar="<disk-format>",
|
||||
choices=DISK_CHOICES,
|
||||
help=_("Image disk format. The supported options are: %s.") %
|
||||
', '.join(DISK_CHOICES)
|
||||
help=_("Image disk format. The supported options are: %s.")
|
||||
% ', '.join(DISK_CHOICES),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--size",
|
||||
metavar="<size>",
|
||||
type=int,
|
||||
help=_("Size of image data (in bytes)")
|
||||
help=_("Size of image data (in bytes)"),
|
||||
)
|
||||
protected_group = parser.add_mutually_exclusive_group()
|
||||
protected_group.add_argument(
|
||||
@ -560,8 +611,10 @@ class SetImage(command.Command):
|
||||
dest="properties",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Set a property on this image "
|
||||
"(repeat option to set multiple properties)"),
|
||||
help=_(
|
||||
"Set a property on this image "
|
||||
"(repeat option to set multiple properties)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--store",
|
||||
@ -593,8 +646,10 @@ class SetImage(command.Command):
|
||||
dest='force',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_("Force image change if volume is in use "
|
||||
"(only meaningful with --volume)"),
|
||||
help=_(
|
||||
"Force image change if volume is in use "
|
||||
"(only meaningful with --volume)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--stdin",
|
||||
@ -619,9 +674,21 @@ class SetImage(command.Command):
|
||||
image_client = self.app.client_manager.image
|
||||
|
||||
kwargs = {}
|
||||
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties',
|
||||
'container_format', 'disk_format', 'size', 'store',
|
||||
'location', 'copy_from', 'volume', 'checksum')
|
||||
copy_attrs = (
|
||||
'name',
|
||||
'owner',
|
||||
'min_disk',
|
||||
'min_ram',
|
||||
'properties',
|
||||
'container_format',
|
||||
'disk_format',
|
||||
'size',
|
||||
'store',
|
||||
'location',
|
||||
'copy_from',
|
||||
'volume',
|
||||
'checksum',
|
||||
)
|
||||
for attr in copy_attrs:
|
||||
if attr in parsed_args:
|
||||
val = getattr(parsed_args, attr, None)
|
||||
@ -665,12 +732,16 @@ class SetImage(command.Command):
|
||||
source_volume.id,
|
||||
parsed_args.force,
|
||||
parsed_args.image,
|
||||
(parsed_args.container_format
|
||||
if parsed_args.container_format
|
||||
else image.container_format),
|
||||
(parsed_args.disk_format
|
||||
if parsed_args.disk_format
|
||||
else image.disk_format),
|
||||
(
|
||||
parsed_args.container_format
|
||||
if parsed_args.container_format
|
||||
else image.container_format
|
||||
),
|
||||
(
|
||||
parsed_args.disk_format
|
||||
if parsed_args.disk_format
|
||||
else image.disk_format
|
||||
),
|
||||
)
|
||||
elif parsed_args.file:
|
||||
# Send an open file handle to glanceclient so it will
|
||||
@ -687,8 +758,12 @@ class SetImage(command.Command):
|
||||
else:
|
||||
kwargs["data"] = sys.stdin
|
||||
else:
|
||||
LOG.warning(_('Use --stdin to enable read image '
|
||||
'data from standard input'))
|
||||
LOG.warning(
|
||||
_(
|
||||
'Use --stdin to enable read image '
|
||||
'data from standard input'
|
||||
)
|
||||
)
|
||||
|
||||
if image.properties and parsed_args.properties:
|
||||
image.properties.update(kwargs['properties'])
|
||||
@ -697,8 +772,11 @@ class SetImage(command.Command):
|
||||
image = image_client.update_image(image.id, **kwargs)
|
||||
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):
|
||||
if (
|
||||
'data' in kwargs
|
||||
and hasattr(kwargs['data'], 'close')
|
||||
and kwargs['data'] != sys.stdin
|
||||
):
|
||||
kwargs['data'].close()
|
||||
|
||||
|
||||
@ -728,6 +806,7 @@ class ShowImage(command.ShowOne):
|
||||
_formatters['size'] = HumanReadableSizeColumn
|
||||
display_columns, columns = _get_columns(image)
|
||||
_formatters['properties'] = format_columns.DictColumn
|
||||
data = utils.get_item_properties(image, columns,
|
||||
formatters=_formatters)
|
||||
data = utils.get_item_properties(
|
||||
image, columns, formatters=_formatters
|
||||
)
|
||||
return (display_columns, data)
|
||||
|
@ -506,8 +506,8 @@ class CreateImage(command.ShowOne):
|
||||
raise exceptions.CommandError(msg)
|
||||
|
||||
if (
|
||||
len(parsed_args.sign_key_path) < 1 or
|
||||
len(parsed_args.sign_cert_id) < 1
|
||||
len(parsed_args.sign_key_path) < 1
|
||||
or len(parsed_args.sign_cert_id) < 1
|
||||
):
|
||||
msg = _(
|
||||
"'sign-key-path' and 'sign-cert-id' must both be "
|
||||
@ -596,10 +596,7 @@ class CreateImage(command.ShowOne):
|
||||
)
|
||||
kwargs = {}
|
||||
if volume_client.api_version < api_versions.APIVersion('3.1'):
|
||||
if (
|
||||
parsed_args.visibility or
|
||||
parsed_args.is_protected is not None
|
||||
):
|
||||
if parsed_args.visibility or parsed_args.is_protected is not None:
|
||||
msg = _(
|
||||
'--os-volume-api-version 3.1 or greater is required '
|
||||
'to support the --public, --private, --community, '
|
||||
@ -618,7 +615,7 @@ class CreateImage(command.ShowOne):
|
||||
parsed_args.name,
|
||||
parsed_args.container_format,
|
||||
parsed_args.disk_format,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
info = body['os-volume_upload_image']
|
||||
try:
|
||||
@ -659,7 +656,6 @@ class DeleteImage(command.Command):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
del_result = 0
|
||||
image_client = self.app.client_manager.image
|
||||
for image in parsed_args.images:
|
||||
|
@ -52,8 +52,9 @@ def _format_namespace(namespace):
|
||||
if key in fields_to_show:
|
||||
info[key] = namespace.get(key)
|
||||
elif key == "resource_type_associations":
|
||||
info[key] = [resource_type['name']
|
||||
for resource_type in namespace.get(key)]
|
||||
info[key] = [
|
||||
resource_type['name'] for resource_type in namespace.get(key)
|
||||
]
|
||||
elif key == 'properties':
|
||||
info['properties'] = list(namespace.get(key).keys())
|
||||
|
||||
@ -114,11 +115,7 @@ class CreateMetadefNameSpace(command.ShowOne):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
image_client = self.app.client_manager.image
|
||||
filter_keys = [
|
||||
'namespace',
|
||||
'display_name',
|
||||
'description'
|
||||
]
|
||||
filter_keys = ['namespace', 'display_name', 'description']
|
||||
kwargs = {}
|
||||
|
||||
for key in filter_keys:
|
||||
@ -160,15 +157,19 @@ class DeleteMetadefNameSpace(command.Command):
|
||||
image_client.delete_metadef_namespace(namespace.id)
|
||||
except Exception as e:
|
||||
result += 1
|
||||
LOG.error(_("Failed to delete namespace with name or "
|
||||
"ID '%(namespace)s': %(e)s"),
|
||||
{'namespace': i, 'e': e}
|
||||
)
|
||||
LOG.error(
|
||||
_(
|
||||
"Failed to delete namespace with name or "
|
||||
"ID '%(namespace)s': %(e)s"
|
||||
),
|
||||
{'namespace': i, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
total = len(parsed_args.namespace_name)
|
||||
msg = (_("%(result)s of %(total)s namespace failed "
|
||||
"to delete.") % {'result': result, 'total': total})
|
||||
msg = _(
|
||||
"%(result)s of %(total)s namespace failed " "to delete."
|
||||
) % {'result': result, 'total': total}
|
||||
raise exceptions.CommandError(msg)
|
||||
|
||||
|
||||
@ -203,11 +204,14 @@ class ListMetadefNameSpaces(command.Lister):
|
||||
column_headers = columns
|
||||
return (
|
||||
column_headers,
|
||||
(utils.get_item_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters=_formatters,
|
||||
) for s in data)
|
||||
(
|
||||
utils.get_item_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters=_formatters,
|
||||
)
|
||||
for s in data
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@ -268,11 +272,7 @@ class SetMetadefNameSpace(command.Command):
|
||||
|
||||
namespace = parsed_args.namespace
|
||||
|
||||
filter_keys = [
|
||||
'namespace',
|
||||
'display_name',
|
||||
'description'
|
||||
]
|
||||
filter_keys = ['namespace', 'display_name', 'description']
|
||||
kwargs = {}
|
||||
|
||||
for key in filter_keys:
|
||||
|
@ -26,9 +26,7 @@ class ImageTests(base.BaseImageTests):
|
||||
if not self.haz_v1_api:
|
||||
self.skipTest('No Image v1 API present')
|
||||
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_IMAGE_API_VERSION', '1'
|
||||
)
|
||||
ver_fixture = fixtures.EnvironmentVariable('OS_IMAGE_API_VERSION', '1')
|
||||
self.useFixture(ver_fixture)
|
||||
|
||||
self.name = uuid.uuid4().hex
|
||||
@ -46,25 +44,20 @@ class ImageTests(base.BaseImageTests):
|
||||
super().tearDown()
|
||||
|
||||
def test_image_list(self):
|
||||
output = self.openstack(
|
||||
'image list'
|
||||
)
|
||||
self.assertIn(
|
||||
self.name,
|
||||
[img['Name'] for img in output]
|
||||
)
|
||||
output = self.openstack('image list')
|
||||
self.assertIn(self.name, [img['Name'] for img in output])
|
||||
|
||||
def test_image_attributes(self):
|
||||
"""Test set, unset, show on attributes, tags and properties"""
|
||||
|
||||
# Test explicit attributes
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--min-disk 4 ' +
|
||||
'--min-ram 5 ' +
|
||||
'--disk-format qcow2 ' +
|
||||
'--public ' +
|
||||
self.name
|
||||
'image set '
|
||||
+ '--min-disk 4 '
|
||||
+ '--min-ram 5 '
|
||||
+ '--disk-format qcow2 '
|
||||
+ '--public '
|
||||
+ self.name
|
||||
)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
@ -88,11 +81,11 @@ class ImageTests(base.BaseImageTests):
|
||||
|
||||
# Test properties
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--property a=b ' +
|
||||
'--property c=d ' +
|
||||
'--public ' +
|
||||
self.name
|
||||
'image set '
|
||||
+ '--property a=b '
|
||||
+ '--property c=d '
|
||||
+ '--public '
|
||||
+ self.name
|
||||
)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
|
@ -23,9 +23,7 @@ class ImageTests(base.BaseImageTests):
|
||||
def setUp(self):
|
||||
super(ImageTests, self).setUp()
|
||||
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_IMAGE_API_VERSION', '2'
|
||||
)
|
||||
ver_fixture = fixtures.EnvironmentVariable('OS_IMAGE_API_VERSION', '2')
|
||||
self.useFixture(ver_fixture)
|
||||
|
||||
self.name = uuid.uuid4().hex
|
||||
@ -33,7 +31,8 @@ class ImageTests(base.BaseImageTests):
|
||||
self.image_tag1 = 'random'
|
||||
output = self.openstack(
|
||||
'image create --tag {tag} {name}'.format(
|
||||
tag=self.image_tag, name=self.name),
|
||||
tag=self.image_tag, name=self.name
|
||||
),
|
||||
parse_output=True,
|
||||
)
|
||||
self.image_id = output["id"]
|
||||
@ -47,57 +46,45 @@ class ImageTests(base.BaseImageTests):
|
||||
|
||||
def test_image_list(self):
|
||||
output = self.openstack('image list', parse_output=True)
|
||||
self.assertIn(
|
||||
self.name,
|
||||
[img['Name'] for img in output]
|
||||
)
|
||||
self.assertIn(self.name, [img['Name'] for img in output])
|
||||
|
||||
def test_image_list_with_name_filter(self):
|
||||
output = self.openstack(
|
||||
'image list --name ' + self.name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(
|
||||
self.name,
|
||||
[img['Name'] for img in output]
|
||||
)
|
||||
self.assertIn(self.name, [img['Name'] for img in output])
|
||||
|
||||
def test_image_list_with_status_filter(self):
|
||||
output = self.openstack(
|
||||
'image list --status active',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(
|
||||
'active',
|
||||
[img['Status'] for img in output]
|
||||
)
|
||||
self.assertIn('active', [img['Status'] for img in output])
|
||||
|
||||
def test_image_list_with_tag_filter(self):
|
||||
output = self.openstack(
|
||||
'image list --tag ' + self.image_tag + ' --tag ' +
|
||||
self.image_tag1 + ' --long',
|
||||
'image list --tag '
|
||||
+ self.image_tag
|
||||
+ ' --tag '
|
||||
+ self.image_tag1
|
||||
+ ' --long',
|
||||
parse_output=True,
|
||||
)
|
||||
for taglist in [img['Tags'] for img in output]:
|
||||
self.assertIn(
|
||||
self.image_tag,
|
||||
taglist
|
||||
)
|
||||
self.assertIn(
|
||||
self.image_tag1,
|
||||
taglist
|
||||
)
|
||||
self.assertIn(self.image_tag, taglist)
|
||||
self.assertIn(self.image_tag1, taglist)
|
||||
|
||||
def test_image_attributes(self):
|
||||
"""Test set, unset, show on attributes, tags and properties"""
|
||||
|
||||
# Test explicit attributes
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--min-disk 4 ' +
|
||||
'--min-ram 5 ' +
|
||||
'--public ' +
|
||||
self.name
|
||||
'image set '
|
||||
+ '--min-disk 4 '
|
||||
+ '--min-ram 5 '
|
||||
+ '--public '
|
||||
+ self.name
|
||||
)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
@ -118,12 +105,12 @@ class ImageTests(base.BaseImageTests):
|
||||
|
||||
# Test properties
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--property a=b ' +
|
||||
'--property c=d ' +
|
||||
'--property hw_rng_model=virtio ' +
|
||||
'--public ' +
|
||||
self.name
|
||||
'image set '
|
||||
+ '--property a=b '
|
||||
+ '--property c=d '
|
||||
+ '--property hw_rng_model=virtio '
|
||||
+ '--public '
|
||||
+ self.name
|
||||
)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
@ -133,11 +120,11 @@ class ImageTests(base.BaseImageTests):
|
||||
self.assertIn("c", output["properties"])
|
||||
|
||||
self.openstack(
|
||||
'image unset ' +
|
||||
'--property a ' +
|
||||
'--property c ' +
|
||||
'--property hw_rng_model ' +
|
||||
self.name
|
||||
'image unset '
|
||||
+ '--property a '
|
||||
+ '--property c '
|
||||
+ '--property hw_rng_model '
|
||||
+ self.name
|
||||
)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
@ -147,37 +134,20 @@ class ImageTests(base.BaseImageTests):
|
||||
self.assertNotIn("c", output["properties"])
|
||||
|
||||
# Test tags
|
||||
self.assertNotIn(
|
||||
'01',
|
||||
output["tags"]
|
||||
)
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--tag 01 ' +
|
||||
self.name
|
||||
)
|
||||
self.assertNotIn('01', output["tags"])
|
||||
self.openstack('image set ' + '--tag 01 ' + self.name)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(
|
||||
'01',
|
||||
output["tags"]
|
||||
)
|
||||
self.assertIn('01', output["tags"])
|
||||
|
||||
self.openstack(
|
||||
'image unset ' +
|
||||
'--tag 01 ' +
|
||||
self.name
|
||||
)
|
||||
self.openstack('image unset ' + '--tag 01 ' + self.name)
|
||||
output = self.openstack(
|
||||
'image show ' + self.name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn(
|
||||
'01',
|
||||
output["tags"]
|
||||
)
|
||||
self.assertNotIn('01', output["tags"])
|
||||
|
||||
def test_image_set_rename(self):
|
||||
name = uuid.uuid4().hex
|
||||
@ -190,11 +160,7 @@ class ImageTests(base.BaseImageTests):
|
||||
name,
|
||||
output["name"],
|
||||
)
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--name ' + name + 'xx ' +
|
||||
image_id
|
||||
)
|
||||
self.openstack('image set ' + '--name ' + name + 'xx ' + image_id)
|
||||
output = self.openstack(
|
||||
'image show ' + name + 'xx',
|
||||
parse_output=True,
|
||||
@ -216,8 +182,7 @@ class ImageTests(base.BaseImageTests):
|
||||
my_project_id = output['project_id']
|
||||
|
||||
output = self.openstack(
|
||||
'image show -f json ' +
|
||||
self.name,
|
||||
'image show -f json ' + self.name,
|
||||
parse_output=True,
|
||||
)
|
||||
# NOTE(dtroyer): Until OSC supports --shared flags in create and set
|
||||
@ -225,9 +190,7 @@ class ImageTests(base.BaseImageTests):
|
||||
# images are shared and sometimes they are not.
|
||||
if output["visibility"] == 'shared':
|
||||
self.openstack(
|
||||
'image add project ' +
|
||||
self.name + ' ' +
|
||||
my_project_id
|
||||
'image add project ' + self.name + ' ' + my_project_id
|
||||
)
|
||||
# self.addCleanup(
|
||||
# self.openstack,
|
||||
@ -236,29 +199,16 @@ class ImageTests(base.BaseImageTests):
|
||||
# my_project_id
|
||||
# )
|
||||
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--accept ' +
|
||||
self.name
|
||||
)
|
||||
self.openstack('image set ' + '--accept ' + self.name)
|
||||
output = self.openstack(
|
||||
'image list -f json ' +
|
||||
'--shared',
|
||||
'image list -f json ' + '--shared',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(
|
||||
self.name,
|
||||
[img['Name'] for img in output]
|
||||
)
|
||||
self.assertIn(self.name, [img['Name'] for img in output])
|
||||
|
||||
self.openstack(
|
||||
'image set ' +
|
||||
'--reject ' +
|
||||
self.name
|
||||
)
|
||||
self.openstack('image set ' + '--reject ' + self.name)
|
||||
output = self.openstack(
|
||||
'image list -f json ' +
|
||||
'--shared',
|
||||
'image list -f json ' + '--shared',
|
||||
parse_output=True,
|
||||
)
|
||||
# self.assertNotIn(
|
||||
@ -267,9 +217,7 @@ class ImageTests(base.BaseImageTests):
|
||||
# )
|
||||
|
||||
self.openstack(
|
||||
'image remove project ' +
|
||||
self.name + ' ' +
|
||||
my_project_id
|
||||
'image remove project ' + self.name + ' ' + my_project_id
|
||||
)
|
||||
|
||||
# else:
|
||||
|
@ -23,7 +23,6 @@ from openstackclient.tests.unit.volume.v1 import fakes as volume_fakes
|
||||
|
||||
|
||||
class FakeImagev1Client:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.images = mock.Mock()
|
||||
|
||||
@ -33,7 +32,6 @@ class FakeImagev1Client:
|
||||
|
||||
|
||||
class TestImagev1(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -71,11 +69,8 @@ def create_one_image(attrs=None):
|
||||
'min_ram': 0,
|
||||
'is_public': True,
|
||||
'protected': False,
|
||||
'properties': {
|
||||
'Alpha': 'a',
|
||||
'Beta': 'b',
|
||||
'Gamma': 'g'},
|
||||
'status': 'status' + uuid.uuid4().hex
|
||||
'properties': {'Alpha': 'a', 'Beta': 'b', 'Gamma': 'g'},
|
||||
'status': 'status' + uuid.uuid4().hex,
|
||||
}
|
||||
|
||||
# Overwrite default attributes if there are some attributes set
|
||||
|
@ -24,12 +24,10 @@ from openstackclient.tests.unit.image.v1 import fakes as image_fakes
|
||||
|
||||
|
||||
class TestImage(image_fakes.TestImagev1):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class TestImageCreate(TestImage):
|
||||
|
||||
new_image = image_fakes.create_one_image()
|
||||
columns = (
|
||||
'container_format',
|
||||
@ -42,7 +40,7 @@ class TestImageCreate(TestImage):
|
||||
'owner',
|
||||
'properties',
|
||||
'protected',
|
||||
'size'
|
||||
'size',
|
||||
)
|
||||
data = (
|
||||
new_image.container_format,
|
||||
@ -55,7 +53,7 @@ class TestImageCreate(TestImage):
|
||||
new_image.owner_id,
|
||||
format_columns.DictColumn(new_image.properties),
|
||||
new_image.is_protected,
|
||||
new_image.size
|
||||
new_image.size,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
@ -89,7 +87,7 @@ class TestImageCreate(TestImage):
|
||||
self.client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
container_format=image.DEFAULT_CONTAINER_FORMAT,
|
||||
disk_format=image.DEFAULT_DISK_FORMAT
|
||||
disk_format=image.DEFAULT_DISK_FORMAT,
|
||||
)
|
||||
|
||||
# Verify update() was not called, if it was show the args
|
||||
@ -101,13 +99,18 @@ class TestImageCreate(TestImage):
|
||||
@mock.patch('sys.stdin', side_effect=[None])
|
||||
def test_image_reserve_options(self, raw_input):
|
||||
arglist = [
|
||||
'--container-format', 'ovf',
|
||||
'--disk-format', 'ami',
|
||||
'--min-disk', '10',
|
||||
'--min-ram', '4',
|
||||
'--container-format',
|
||||
'ovf',
|
||||
'--disk-format',
|
||||
'ami',
|
||||
'--min-disk',
|
||||
'10',
|
||||
'--min-ram',
|
||||
'4',
|
||||
'--protected',
|
||||
'--private',
|
||||
'--project', 'q',
|
||||
'--project',
|
||||
'q',
|
||||
self.new_image.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -154,11 +157,14 @@ class TestImageCreate(TestImage):
|
||||
mock_open.read.return_value = self.data
|
||||
|
||||
arglist = [
|
||||
'--file', 'filer',
|
||||
'--file',
|
||||
'filer',
|
||||
'--unprotected',
|
||||
'--public',
|
||||
'--property', 'Alpha=1',
|
||||
'--property', 'Beta=2',
|
||||
'--property',
|
||||
'Alpha=1',
|
||||
'--property',
|
||||
'Beta=2',
|
||||
self.new_image.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -205,7 +211,6 @@ class TestImageCreate(TestImage):
|
||||
|
||||
|
||||
class TestImageDelete(TestImage):
|
||||
|
||||
_image = image_fakes.create_one_image()
|
||||
|
||||
def setUp(self):
|
||||
@ -234,7 +239,6 @@ class TestImageDelete(TestImage):
|
||||
|
||||
|
||||
class TestImageList(TestImage):
|
||||
|
||||
_image = image_fakes.create_one_image()
|
||||
|
||||
columns = (
|
||||
@ -242,13 +246,7 @@ class TestImageList(TestImage):
|
||||
'Name',
|
||||
'Status',
|
||||
)
|
||||
datalist = (
|
||||
(
|
||||
_image.id,
|
||||
_image.name,
|
||||
_image.status
|
||||
),
|
||||
)
|
||||
datalist = ((_image.id, _image.name, _image.status),)
|
||||
|
||||
# create a image_info as the side_effect of the fake image_list()
|
||||
info = {
|
||||
@ -270,7 +268,8 @@ class TestImageList(TestImage):
|
||||
|
||||
self.client.images = mock.Mock()
|
||||
self.client.images.side_effect = [
|
||||
[self._image], [],
|
||||
[self._image],
|
||||
[],
|
||||
]
|
||||
|
||||
# Get the command object to test
|
||||
@ -368,30 +367,35 @@ class TestImageList(TestImage):
|
||||
)
|
||||
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
self._image.id,
|
||||
self._image.name,
|
||||
self._image.disk_format,
|
||||
self._image.container_format,
|
||||
self._image.size,
|
||||
self._image.checksum,
|
||||
self._image.status,
|
||||
image.VisibilityColumn(self._image.is_public),
|
||||
self._image.is_protected,
|
||||
self._image.owner_id,
|
||||
format_columns.DictColumn(
|
||||
{'Alpha': 'a', 'Beta': 'b', 'Gamma': 'g'}),
|
||||
), )
|
||||
datalist = (
|
||||
(
|
||||
self._image.id,
|
||||
self._image.name,
|
||||
self._image.disk_format,
|
||||
self._image.container_format,
|
||||
self._image.size,
|
||||
self._image.checksum,
|
||||
self._image.status,
|
||||
image.VisibilityColumn(self._image.is_public),
|
||||
self._image.is_protected,
|
||||
self._image.owner_id,
|
||||
format_columns.DictColumn(
|
||||
{'Alpha': 'a', 'Beta': 'b', 'Gamma': 'g'}
|
||||
),
|
||||
),
|
||||
)
|
||||
self.assertCountEqual(datalist, tuple(data))
|
||||
|
||||
@mock.patch('osc_lib.api.utils.simple_filter')
|
||||
def test_image_list_property_option(self, sf_mock):
|
||||
sf_mock.side_effect = [
|
||||
[self.image_info], [],
|
||||
[self.image_info],
|
||||
[],
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--property', 'a=1',
|
||||
'--property',
|
||||
'a=1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'a': '1'}),
|
||||
@ -416,7 +420,8 @@ class TestImageList(TestImage):
|
||||
@mock.patch('osc_lib.utils.sort_items')
|
||||
def test_image_list_sort_option(self, si_mock):
|
||||
si_mock.side_effect = [
|
||||
[self._image], [],
|
||||
[self._image],
|
||||
[],
|
||||
]
|
||||
|
||||
arglist = ['--sort', 'name:asc']
|
||||
@ -428,17 +433,13 @@ class TestImageList(TestImage):
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
si_mock.assert_called_with(
|
||||
[self._image],
|
||||
'name:asc'
|
||||
)
|
||||
si_mock.assert_called_with([self._image], 'name:asc')
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
|
||||
class TestImageSet(TestImage):
|
||||
|
||||
_image = image_fakes.create_one_image()
|
||||
|
||||
def setUp(self):
|
||||
@ -467,13 +468,20 @@ class TestImageSet(TestImage):
|
||||
|
||||
def test_image_set_options(self):
|
||||
arglist = [
|
||||
'--name', 'new-name',
|
||||
'--min-disk', '2',
|
||||
'--min-ram', '4',
|
||||
'--container-format', 'ovf',
|
||||
'--disk-format', 'vmdk',
|
||||
'--size', '35165824',
|
||||
'--project', 'new-owner',
|
||||
'--name',
|
||||
'new-name',
|
||||
'--min-disk',
|
||||
'2',
|
||||
'--min-ram',
|
||||
'4',
|
||||
'--container-format',
|
||||
'ovf',
|
||||
'--disk-format',
|
||||
'vmdk',
|
||||
'--size',
|
||||
'35165824',
|
||||
'--project',
|
||||
'new-owner',
|
||||
self._image.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -497,13 +505,10 @@ class TestImageSet(TestImage):
|
||||
'min_ram': 4,
|
||||
'container_format': 'ovf',
|
||||
'disk_format': 'vmdk',
|
||||
'size': 35165824
|
||||
'size': 35165824,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(
|
||||
self._image.id,
|
||||
**kwargs
|
||||
)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_bools1(self):
|
||||
@ -528,10 +533,7 @@ class TestImageSet(TestImage):
|
||||
'is_public': False,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(
|
||||
self._image.id,
|
||||
**kwargs
|
||||
)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_bools2(self):
|
||||
@ -556,16 +558,15 @@ class TestImageSet(TestImage):
|
||||
'is_public': True,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(
|
||||
self._image.id,
|
||||
**kwargs
|
||||
)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_properties(self):
|
||||
arglist = [
|
||||
'--property', 'Alpha=1',
|
||||
'--property', 'Beta=2',
|
||||
'--property',
|
||||
'Alpha=1',
|
||||
'--property',
|
||||
'Beta=2',
|
||||
self._image.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -584,10 +585,7 @@ class TestImageSet(TestImage):
|
||||
},
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(
|
||||
self._image.id,
|
||||
**kwargs
|
||||
)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_update_volume(self):
|
||||
@ -614,8 +612,10 @@ class TestImageSet(TestImage):
|
||||
volumes_mock.upload_to_image.return_value = (201, full_response)
|
||||
|
||||
arglist = [
|
||||
'--volume', 'volly',
|
||||
'--name', 'updated_image',
|
||||
'--volume',
|
||||
'volly',
|
||||
'--name',
|
||||
'updated_image',
|
||||
self._image.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -651,8 +651,10 @@ class TestImageSet(TestImage):
|
||||
|
||||
def test_image_set_numeric_options_to_zero(self):
|
||||
arglist = [
|
||||
'--min-disk', '0',
|
||||
'--min-ram', '0',
|
||||
'--min-disk',
|
||||
'0',
|
||||
'--min-ram',
|
||||
'0',
|
||||
self._image.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -669,15 +671,11 @@ class TestImageSet(TestImage):
|
||||
'min_ram': 0,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(
|
||||
self._image.id,
|
||||
**kwargs
|
||||
)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestImageShow(TestImage):
|
||||
|
||||
_image = image_fakes.create_one_image(attrs={'size': 2000})
|
||||
columns = (
|
||||
'container_format',
|
||||
|
@ -28,7 +28,6 @@ from openstackclient.tests.unit import utils
|
||||
|
||||
|
||||
class FakeImagev2Client:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.images = mock.Mock()
|
||||
self.create_image = mock.Mock()
|
||||
@ -62,7 +61,6 @@ class FakeImagev2Client:
|
||||
|
||||
|
||||
class TestImagev2(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -162,7 +160,7 @@ def create_one_import_info(attrs=None):
|
||||
'web-download',
|
||||
'glance-download',
|
||||
'copy-image',
|
||||
]
|
||||
],
|
||||
}
|
||||
}
|
||||
import_info.update(attrs)
|
||||
@ -188,10 +186,10 @@ def create_one_task(attrs=None):
|
||||
'input': {
|
||||
'image_properties': {
|
||||
'container_format': 'ovf',
|
||||
'disk_format': 'vhd'
|
||||
'disk_format': 'vhd',
|
||||
},
|
||||
'import_from': 'https://apps.openstack.org/excellent-image',
|
||||
'import_from_format': 'qcow2'
|
||||
'import_from_format': 'qcow2',
|
||||
},
|
||||
'message': '',
|
||||
'owner': str(uuid.uuid4()),
|
||||
@ -237,7 +235,6 @@ def create_tasks(attrs=None, count=2):
|
||||
|
||||
|
||||
class FakeMetadefNamespaceClient:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.create_metadef_namespace = mock.Mock()
|
||||
self.delete_metadef_namespace = mock.Mock()
|
||||
@ -251,7 +248,6 @@ class FakeMetadefNamespaceClient:
|
||||
|
||||
|
||||
class TestMetadefNamespaces(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,7 +45,7 @@ class TestMetadefNamespaceCreate(TestMetadefNamespaces):
|
||||
'owner',
|
||||
'resource_type_associations',
|
||||
'updated_at',
|
||||
'visibility'
|
||||
'visibility',
|
||||
)
|
||||
expected_data = (
|
||||
_metadef_namespace.created_at,
|
||||
@ -59,25 +59,22 @@ class TestMetadefNamespaceCreate(TestMetadefNamespaces):
|
||||
_metadef_namespace.owner,
|
||||
_metadef_namespace.resource_type_associations,
|
||||
_metadef_namespace.updated_at,
|
||||
_metadef_namespace.visibility
|
||||
_metadef_namespace.visibility,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.create_metadef_namespace.return_value \
|
||||
= self._metadef_namespace
|
||||
self.client.create_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.CreateMetadefNameSpace(self.app, None)
|
||||
self.datalist = self._metadef_namespace
|
||||
|
||||
def test_namespace_create(self):
|
||||
arglist = [
|
||||
self._metadef_namespace.namespace
|
||||
]
|
||||
arglist = [self._metadef_namespace.namespace]
|
||||
|
||||
verifylist = [
|
||||
|
||||
]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
@ -92,19 +89,16 @@ class TestMetadefNamespaceDelete(TestMetadefNamespaces):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.delete_metadef_namespace.return_value \
|
||||
= self._metadef_namespace
|
||||
self.client.delete_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.DeleteMetadefNameSpace(self.app, None)
|
||||
self.datalist = self._metadef_namespace
|
||||
|
||||
def test_namespace_create(self):
|
||||
arglist = [
|
||||
self._metadef_namespace.namespace
|
||||
]
|
||||
arglist = [self._metadef_namespace.namespace]
|
||||
|
||||
verifylist = [
|
||||
|
||||
]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
@ -115,9 +109,7 @@ class TestMetadefNamespaceDelete(TestMetadefNamespaces):
|
||||
class TestMetadefNamespaceList(TestMetadefNamespaces):
|
||||
_metadef_namespace = [md_namespace_fakes.create_one_metadef_namespace()]
|
||||
|
||||
columns = [
|
||||
'namespace'
|
||||
]
|
||||
columns = ['namespace']
|
||||
|
||||
datalist = []
|
||||
|
||||
@ -125,7 +117,9 @@ class TestMetadefNamespaceList(TestMetadefNamespaces):
|
||||
super().setUp()
|
||||
|
||||
self.client.metadef_namespaces.side_effect = [
|
||||
self._metadef_namespace, []]
|
||||
self._metadef_namespace,
|
||||
[],
|
||||
]
|
||||
|
||||
# Get the command object to test
|
||||
self.client.metadef_namespaces.return_value = iter(
|
||||
@ -144,8 +138,7 @@ class TestMetadefNamespaceList(TestMetadefNamespaces):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(getattr(self.datalist[0], 'namespace'),
|
||||
next(data)[0])
|
||||
self.assertEqual(getattr(self.datalist[0], 'namespace'), next(data)[0])
|
||||
|
||||
|
||||
class TestMetadefNamespaceSet(TestMetadefNamespaces):
|
||||
@ -154,15 +147,14 @@ class TestMetadefNamespaceSet(TestMetadefNamespaces):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.update_metadef_namespace.return_value \
|
||||
= self._metadef_namespace
|
||||
self.client.update_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.SetMetadefNameSpace(self.app, None)
|
||||
self.datalist = self._metadef_namespace
|
||||
|
||||
def test_namespace_set_no_options(self):
|
||||
arglist = [
|
||||
self._metadef_namespace.namespace
|
||||
]
|
||||
arglist = [self._metadef_namespace.namespace]
|
||||
verifylist = [
|
||||
('namespace', self._metadef_namespace.namespace),
|
||||
]
|
||||
@ -182,31 +174,28 @@ class TestMetadefNamespaceShow(TestMetadefNamespaces):
|
||||
'display_name',
|
||||
'namespace',
|
||||
'owner',
|
||||
'visibility'
|
||||
'visibility',
|
||||
)
|
||||
expected_data = (
|
||||
_metadef_namespace.created_at,
|
||||
_metadef_namespace.display_name,
|
||||
_metadef_namespace.namespace,
|
||||
_metadef_namespace.owner,
|
||||
_metadef_namespace.visibility
|
||||
_metadef_namespace.visibility,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.get_metadef_namespace.return_value \
|
||||
= self._metadef_namespace
|
||||
self.client.get_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.ShowMetadefNameSpace(self.app, None)
|
||||
|
||||
def test_namespace_show_no_options(self):
|
||||
arglist = [
|
||||
self._metadef_namespace.namespace
|
||||
]
|
||||
arglist = [self._metadef_namespace.namespace]
|
||||
|
||||
verifylist = [
|
||||
|
||||
]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
@ -25,7 +25,6 @@ class TestTask(image_fakes.TestImagev2):
|
||||
|
||||
|
||||
class TestTaskShow(TestTask):
|
||||
|
||||
task = image_fakes.create_one_task()
|
||||
|
||||
columns = (
|
||||
@ -81,7 +80,6 @@ class TestTaskShow(TestTask):
|
||||
|
||||
|
||||
class TestTaskList(TestTask):
|
||||
|
||||
tasks = image_fakes.create_tasks()
|
||||
|
||||
columns = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user