Blacken openstackclient.object
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: I6658e76d7d1f93149f24fcab28d593195b37779f Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
aed521d426
commit
329296cedd
@ -50,7 +50,8 @@ def build_option_parser(parser):
|
||||
'--os-object-api-version',
|
||||
metavar='<object-api-version>',
|
||||
default=utils.env('OS_OBJECT_API_VERSION'),
|
||||
help='Object API version, default=' +
|
||||
DEFAULT_API_VERSION +
|
||||
' (Env: OS_OBJECT_API_VERSION)')
|
||||
help='Object API version, default='
|
||||
+ DEFAULT_API_VERSION
|
||||
+ ' (Env: OS_OBJECT_API_VERSION)',
|
||||
)
|
||||
return parser
|
||||
|
@ -30,8 +30,10 @@ class SetAccount(command.Command):
|
||||
metavar="<key=value>",
|
||||
required=True,
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Set a property on this account "
|
||||
"(repeat option to set multiple properties)")
|
||||
help=_(
|
||||
"Set a property on this account "
|
||||
"(repeat option to set multiple properties)"
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -48,7 +50,8 @@ class ShowAccount(command.ShowOne):
|
||||
data = self.app.client_manager.object_store.account_show()
|
||||
if 'properties' in data:
|
||||
data['properties'] = format_columns.DictColumn(
|
||||
data.pop('properties'))
|
||||
data.pop('properties')
|
||||
)
|
||||
return zip(*sorted(data.items()))
|
||||
|
||||
|
||||
@ -63,8 +66,10 @@ class UnsetAccount(command.Command):
|
||||
required=True,
|
||||
action='append',
|
||||
default=[],
|
||||
help=_('Property to remove from account '
|
||||
'(repeat option to remove multiple properties)'),
|
||||
help=_(
|
||||
'Property to remove from account '
|
||||
'(repeat option to remove multiple properties)'
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
|
@ -37,11 +37,11 @@ class CreateContainer(command.Lister):
|
||||
'--public',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Make the container publicly accessible"
|
||||
help="Make the container publicly accessible",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--storage-policy',
|
||||
help="Specify a particular storage policy to use."
|
||||
help="Specify a particular storage policy to use.",
|
||||
)
|
||||
parser.add_argument(
|
||||
'containers',
|
||||
@ -52,26 +52,33 @@ class CreateContainer(command.Lister):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
results = []
|
||||
for container in parsed_args.containers:
|
||||
if len(container) > 256:
|
||||
LOG.warning(
|
||||
_('Container name is %s characters long, the default limit'
|
||||
' is 256'), len(container))
|
||||
msg = _(
|
||||
'Container name is %d characters long, the default limit'
|
||||
' is 256'
|
||||
)
|
||||
LOG.warning(msg, len(container))
|
||||
data = self.app.client_manager.object_store.container_create(
|
||||
container=container,
|
||||
public=parsed_args.public,
|
||||
storage_policy=parsed_args.storage_policy
|
||||
storage_policy=parsed_args.storage_policy,
|
||||
)
|
||||
results.append(data)
|
||||
|
||||
columns = ("account", "container", "x-trans-id")
|
||||
return (columns,
|
||||
(utils.get_dict_properties(
|
||||
s, columns,
|
||||
return (
|
||||
columns,
|
||||
(
|
||||
utils.get_dict_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters={},
|
||||
) for s in results))
|
||||
)
|
||||
for s in results
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class DeleteContainer(command.Command):
|
||||
@ -80,7 +87,8 @@ class DeleteContainer(command.Command):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteContainer, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--recursive', '-r',
|
||||
'--recursive',
|
||||
'-r',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Recursively delete objects and container'),
|
||||
@ -94,11 +102,11 @@ class DeleteContainer(command.Command):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
for container in parsed_args.containers:
|
||||
if parsed_args.recursive:
|
||||
objs = self.app.client_manager.object_store.object_list(
|
||||
container=container)
|
||||
container=container
|
||||
)
|
||||
for obj in objs:
|
||||
self.app.client_manager.object_store.object_delete(
|
||||
container=container,
|
||||
@ -150,7 +158,6 @@ class ListContainer(command.Lister):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
if parsed_args.long:
|
||||
columns = ('Name', 'Bytes', 'Count')
|
||||
else:
|
||||
@ -168,15 +175,19 @@ class ListContainer(command.Lister):
|
||||
if parsed_args.all:
|
||||
kwargs['full_listing'] = True
|
||||
|
||||
data = self.app.client_manager.object_store.container_list(
|
||||
**kwargs
|
||||
)
|
||||
data = self.app.client_manager.object_store.container_list(**kwargs)
|
||||
|
||||
return (columns,
|
||||
(utils.get_dict_properties(
|
||||
s, columns,
|
||||
return (
|
||||
columns,
|
||||
(
|
||||
utils.get_dict_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters={},
|
||||
) for s in data))
|
||||
)
|
||||
for s in data
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class SaveContainer(command.Command):
|
||||
@ -212,8 +223,10 @@ class SetContainer(command.Command):
|
||||
metavar="<key=value>",
|
||||
required=True,
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Set a property on this container "
|
||||
"(repeat option to set multiple properties)")
|
||||
help=_(
|
||||
"Set a property on this container "
|
||||
"(repeat option to set multiple properties)"
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -237,7 +250,6 @@ class ShowContainer(command.ShowOne):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
data = self.app.client_manager.object_store.container_show(
|
||||
container=parsed_args.container,
|
||||
)
|
||||
@ -263,8 +275,10 @@ class UnsetContainer(command.Command):
|
||||
required=True,
|
||||
action='append',
|
||||
default=[],
|
||||
help=_('Property to remove from container '
|
||||
'(repeat option to remove multiple properties)'),
|
||||
help=_(
|
||||
'Property to remove from container '
|
||||
'(repeat option to remove multiple properties)'
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
|
@ -48,23 +48,31 @@ class CreateObject(command.Lister):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
metavar='<name>',
|
||||
help=_('Upload a file and rename it. '
|
||||
'Can only be used when uploading a single object')
|
||||
help=_(
|
||||
'Upload a file and rename it. '
|
||||
'Can only be used when uploading a single object'
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
if parsed_args.name:
|
||||
if len(parsed_args.objects) > 1:
|
||||
msg = _('Attempting to upload multiple objects and '
|
||||
'using --name is not permitted')
|
||||
msg = _(
|
||||
'Attempting to upload multiple objects and '
|
||||
'using --name is not permitted'
|
||||
)
|
||||
raise exceptions.CommandError(msg)
|
||||
results = []
|
||||
for obj in parsed_args.objects:
|
||||
if len(obj) > 1024:
|
||||
LOG.warning(
|
||||
_('Object name is %s characters long, default limit'
|
||||
' is 1024'), len(obj))
|
||||
_(
|
||||
'Object name is %s characters long, default limit'
|
||||
' is 1024'
|
||||
),
|
||||
len(obj),
|
||||
)
|
||||
data = self.app.client_manager.object_store.object_create(
|
||||
container=parsed_args.container,
|
||||
object=obj,
|
||||
@ -73,11 +81,17 @@ class CreateObject(command.Lister):
|
||||
results.append(data)
|
||||
|
||||
columns = ("object", "container", "etag")
|
||||
return (columns,
|
||||
(utils.get_dict_properties(
|
||||
s, columns,
|
||||
return (
|
||||
columns,
|
||||
(
|
||||
utils.get_dict_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters={},
|
||||
) for s in results))
|
||||
)
|
||||
for s in results
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class DeleteObject(command.Command):
|
||||
@ -99,7 +113,6 @@ class DeleteObject(command.Command):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
for obj in parsed_args.objects:
|
||||
self.app.client_manager.object_store.object_delete(
|
||||
container=parsed_args.container,
|
||||
@ -158,7 +171,6 @@ class ListObject(command.Lister):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
if parsed_args.long:
|
||||
columns = (
|
||||
'Name',
|
||||
@ -185,15 +197,20 @@ class ListObject(command.Lister):
|
||||
kwargs['full_listing'] = True
|
||||
|
||||
data = self.app.client_manager.object_store.object_list(
|
||||
container=parsed_args.container,
|
||||
**kwargs
|
||||
container=parsed_args.container, **kwargs
|
||||
)
|
||||
|
||||
return (columns,
|
||||
(utils.get_dict_properties(
|
||||
s, columns,
|
||||
return (
|
||||
columns,
|
||||
(
|
||||
utils.get_dict_properties(
|
||||
s,
|
||||
columns,
|
||||
formatters={},
|
||||
) for s in data))
|
||||
)
|
||||
for s in data
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class SaveObject(command.Command):
|
||||
@ -204,8 +221,10 @@ class SaveObject(command.Command):
|
||||
parser.add_argument(
|
||||
"--file",
|
||||
metavar="<filename>",
|
||||
help=_("Destination filename (defaults to object name); using '-'"
|
||||
" as the filename will print the file to stdout"),
|
||||
help=_(
|
||||
"Destination filename (defaults to object name); using '-'"
|
||||
" as the filename will print the file to stdout"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'container',
|
||||
@ -247,8 +266,10 @@ class SetObject(command.Command):
|
||||
metavar="<key=value>",
|
||||
required=True,
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Set a property on this object "
|
||||
"(repeat option to set multiple properties)")
|
||||
help=_(
|
||||
"Set a property on this object "
|
||||
"(repeat option to set multiple properties)"
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -278,7 +299,6 @@ class ShowObject(command.ShowOne):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
data = self.app.client_manager.object_store.object_show(
|
||||
container=parsed_args.container,
|
||||
object=parsed_args.object,
|
||||
@ -310,8 +330,10 @@ class UnsetObject(command.Command):
|
||||
required=True,
|
||||
action='append',
|
||||
default=[],
|
||||
help=_('Property to remove from object '
|
||||
'(repeat option to remove multiple properties)'),
|
||||
help=_(
|
||||
'Property to remove from object '
|
||||
'(repeat option to remove multiple properties)'
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
|
@ -18,6 +18,7 @@ from openstackclient.tests.functional.object.v1 import common
|
||||
|
||||
class ContainerTests(common.ObjectStoreTests):
|
||||
"""Functional tests for Object Store container commands"""
|
||||
|
||||
NAME = uuid.uuid4().hex
|
||||
|
||||
@classmethod
|
||||
|
@ -53,8 +53,9 @@ class ObjectTests(common.ObjectStoreTests):
|
||||
self.openstack('container save ' + self.CONTAINER_NAME)
|
||||
# TODO(stevemar): Assert returned fields
|
||||
|
||||
raw_output = self.openstack('object create %s %s' %
|
||||
(self.CONTAINER_NAME, object_file))
|
||||
raw_output = self.openstack(
|
||||
'object create %s %s' % (self.CONTAINER_NAME, object_file)
|
||||
)
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_show_fields(items, OBJECT_FIELDS)
|
||||
|
||||
@ -62,30 +63,38 @@ class ObjectTests(common.ObjectStoreTests):
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_table_structure(items, BASIC_LIST_HEADERS)
|
||||
|
||||
self.openstack('object save %s %s' %
|
||||
(self.CONTAINER_NAME, object_file))
|
||||
self.openstack(
|
||||
'object save %s %s' % (self.CONTAINER_NAME, object_file)
|
||||
)
|
||||
# TODO(stevemar): Assert returned fields
|
||||
|
||||
tmp_file = 'tmp.txt'
|
||||
self.addCleanup(os.remove, tmp_file)
|
||||
self.openstack('object save %s %s --file %s' %
|
||||
(self.CONTAINER_NAME, object_file, tmp_file))
|
||||
self.openstack(
|
||||
'object save %s %s --file %s'
|
||||
% (self.CONTAINER_NAME, object_file, tmp_file)
|
||||
)
|
||||
# TODO(stevemar): Assert returned fields
|
||||
|
||||
raw_output = self.openstack('object save %s %s --file -' %
|
||||
(self.CONTAINER_NAME, object_file))
|
||||
raw_output = self.openstack(
|
||||
'object save %s %s --file -' % (self.CONTAINER_NAME, object_file)
|
||||
)
|
||||
self.assertEqual(raw_output, 'test content')
|
||||
|
||||
self.openstack('object show %s %s' %
|
||||
(self.CONTAINER_NAME, object_file))
|
||||
self.openstack(
|
||||
'object show %s %s' % (self.CONTAINER_NAME, object_file)
|
||||
)
|
||||
# TODO(stevemar): Assert returned fields
|
||||
|
||||
raw_output = self.openstack('object delete %s %s' %
|
||||
(self.CONTAINER_NAME, object_file))
|
||||
raw_output = self.openstack(
|
||||
'object delete %s %s' % (self.CONTAINER_NAME, object_file)
|
||||
)
|
||||
self.assertEqual(0, len(raw_output))
|
||||
|
||||
self.openstack('object create %s %s' %
|
||||
(self.CONTAINER_NAME, object_file))
|
||||
raw_output = self.openstack('container delete -r %s' %
|
||||
self.CONTAINER_NAME)
|
||||
self.openstack(
|
||||
'object create %s %s' % (self.CONTAINER_NAME, object_file)
|
||||
)
|
||||
raw_output = self.openstack(
|
||||
'container delete -r %s' % self.CONTAINER_NAME
|
||||
)
|
||||
self.assertEqual(0, len(raw_output))
|
||||
|
@ -81,7 +81,6 @@ object_upload_name = 'test-object-name'
|
||||
|
||||
|
||||
class TestObjectv1(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectv1, self).setUp()
|
||||
|
||||
|
@ -26,14 +26,12 @@ AUTH_URL = "http://0.0.0.0"
|
||||
|
||||
|
||||
class FakeClient(object):
|
||||
|
||||
def __init__(self, endpoint=None, **kwargs):
|
||||
self.endpoint = AUTH_URL
|
||||
self.token = AUTH_TOKEN
|
||||
|
||||
|
||||
class TestContainer(object_fakes.TestObjectv1):
|
||||
|
||||
columns = ('Name',)
|
||||
|
||||
def setUp(self):
|
||||
@ -49,7 +47,6 @@ class TestContainer(object_fakes.TestObjectv1):
|
||||
@mock.patch('openstackclient.api.object_store_v1.APIv1.object_list')
|
||||
@mock.patch('openstackclient.api.object_store_v1.APIv1.container_delete')
|
||||
class TestContainerDelete(TestContainer):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerDelete, self).setUp()
|
||||
|
||||
@ -72,8 +69,7 @@ class TestContainerDelete(TestContainer):
|
||||
|
||||
kwargs = {}
|
||||
c_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
**kwargs
|
||||
container=object_fakes.container_name, **kwargs
|
||||
)
|
||||
self.assertFalse(o_list_mock.called)
|
||||
self.assertFalse(o_delete_mock.called)
|
||||
@ -97,8 +93,7 @@ class TestContainerDelete(TestContainer):
|
||||
|
||||
kwargs = {}
|
||||
c_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
**kwargs
|
||||
container=object_fakes.container_name, **kwargs
|
||||
)
|
||||
o_list_mock.assert_called_with(container=object_fakes.container_name)
|
||||
o_delete_mock.assert_called_with(
|
||||
@ -125,8 +120,7 @@ class TestContainerDelete(TestContainer):
|
||||
|
||||
kwargs = {}
|
||||
c_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
**kwargs
|
||||
container=object_fakes.container_name, **kwargs
|
||||
)
|
||||
o_list_mock.assert_called_with(container=object_fakes.container_name)
|
||||
o_delete_mock.assert_called_with(
|
||||
@ -135,11 +129,8 @@ class TestContainerDelete(TestContainer):
|
||||
)
|
||||
|
||||
|
||||
@mock.patch(
|
||||
'openstackclient.api.object_store_v1.APIv1.container_list'
|
||||
)
|
||||
@mock.patch('openstackclient.api.object_store_v1.APIv1.container_list')
|
||||
class TestContainerList(TestContainer):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerList, self).setUp()
|
||||
|
||||
@ -163,17 +154,14 @@ class TestContainerList(TestContainer):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
}
|
||||
c_mock.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
kwargs = {}
|
||||
c_mock.assert_called_with(**kwargs)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name_2, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_3,),
|
||||
(object_fakes.container_name_2,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -184,7 +172,8 @@ class TestContainerList(TestContainer):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--prefix', 'bit',
|
||||
'--prefix',
|
||||
'bit',
|
||||
]
|
||||
verifylist = [
|
||||
('prefix', 'bit'),
|
||||
@ -200,14 +189,12 @@ class TestContainerList(TestContainer):
|
||||
kwargs = {
|
||||
'prefix': 'bit',
|
||||
}
|
||||
c_mock.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
c_mock.assert_called_with(**kwargs)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_3,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -218,8 +205,10 @@ class TestContainerList(TestContainer):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--marker', object_fakes.container_name,
|
||||
'--end-marker', object_fakes.container_name_3,
|
||||
'--marker',
|
||||
object_fakes.container_name,
|
||||
'--end-marker',
|
||||
object_fakes.container_name_3,
|
||||
]
|
||||
verifylist = [
|
||||
('marker', object_fakes.container_name),
|
||||
@ -237,14 +226,12 @@ class TestContainerList(TestContainer):
|
||||
'marker': object_fakes.container_name,
|
||||
'end_marker': object_fakes.container_name_3,
|
||||
}
|
||||
c_mock.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
c_mock.assert_called_with(**kwargs)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_3,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -255,7 +242,8 @@ class TestContainerList(TestContainer):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--limit', '2',
|
||||
'--limit',
|
||||
'2',
|
||||
]
|
||||
verifylist = [
|
||||
('limit', 2),
|
||||
@ -271,14 +259,12 @@ class TestContainerList(TestContainer):
|
||||
kwargs = {
|
||||
'limit': 2,
|
||||
}
|
||||
c_mock.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
c_mock.assert_called_with(**kwargs)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_3,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -302,11 +288,8 @@ class TestContainerList(TestContainer):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
}
|
||||
c_mock.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
kwargs = {}
|
||||
c_mock.assert_called_with(**kwargs)
|
||||
|
||||
collist = ('Name', 'Bytes', 'Count')
|
||||
self.assertEqual(collist, columns)
|
||||
@ -348,24 +331,19 @@ class TestContainerList(TestContainer):
|
||||
kwargs = {
|
||||
'full_listing': True,
|
||||
}
|
||||
c_mock.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
c_mock.assert_called_with(**kwargs)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_2, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_2,),
|
||||
(object_fakes.container_name_3,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
||||
@mock.patch(
|
||||
'openstackclient.api.object_store_v1.APIv1.container_show'
|
||||
)
|
||||
@mock.patch('openstackclient.api.object_store_v1.APIv1.container_show')
|
||||
class TestContainerShow(TestContainer):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerShow, self).setUp()
|
||||
|
||||
@ -389,12 +367,10 @@ class TestContainerShow(TestContainer):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
}
|
||||
kwargs = {}
|
||||
# lib.container.show_container(api, url, container)
|
||||
c_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
**kwargs
|
||||
container=object_fakes.container_name, **kwargs
|
||||
)
|
||||
|
||||
collist = ('bytes', 'count', 'name')
|
||||
|
@ -20,7 +20,6 @@ from openstackclient.tests.unit.object.v1 import fakes as object_fakes
|
||||
|
||||
|
||||
class TestContainerAll(object_fakes.TestObjectv1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerAll, self).setUp()
|
||||
|
||||
@ -28,7 +27,6 @@ class TestContainerAll(object_fakes.TestObjectv1):
|
||||
|
||||
|
||||
class TestContainerCreate(TestContainerAll):
|
||||
|
||||
columns = (
|
||||
'account',
|
||||
'container',
|
||||
@ -52,9 +50,12 @@ class TestContainerCreate(TestContainerAll):
|
||||
arglist = [
|
||||
'ernie',
|
||||
]
|
||||
verifylist = [(
|
||||
'containers', ['ernie'],
|
||||
)]
|
||||
verifylist = [
|
||||
(
|
||||
'containers',
|
||||
['ernie'],
|
||||
)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class ShowOne in cliff, abstract method take_action()
|
||||
@ -63,32 +64,27 @@ class TestContainerCreate(TestContainerAll):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = [(
|
||||
object_fakes.ACCOUNT_ID,
|
||||
'ernie',
|
||||
'314159',
|
||||
)]
|
||||
datalist = [
|
||||
(
|
||||
object_fakes.ACCOUNT_ID,
|
||||
'ernie',
|
||||
'314159',
|
||||
)
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
||||
def test_object_create_container_storage_policy(self):
|
||||
self.requests_mock.register_uri(
|
||||
'PUT',
|
||||
object_fakes.ENDPOINT + '/ernie',
|
||||
headers={
|
||||
'x-trans-id': '314159',
|
||||
'x-storage-policy': 'o1--sr-r3'
|
||||
},
|
||||
headers={'x-trans-id': '314159', 'x-storage-policy': 'o1--sr-r3'},
|
||||
status_code=200,
|
||||
)
|
||||
|
||||
arglist = [
|
||||
'ernie',
|
||||
'--storage-policy',
|
||||
'o1--sr-r3'
|
||||
]
|
||||
arglist = ['ernie', '--storage-policy', 'o1--sr-r3']
|
||||
verifylist = [
|
||||
('containers', ['ernie']),
|
||||
('storage_policy', 'o1--sr-r3')
|
||||
('storage_policy', 'o1--sr-r3'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -98,11 +94,13 @@ class TestContainerCreate(TestContainerAll):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = [(
|
||||
object_fakes.ACCOUNT_ID,
|
||||
'ernie',
|
||||
'314159',
|
||||
)]
|
||||
datalist = [
|
||||
(
|
||||
object_fakes.ACCOUNT_ID,
|
||||
'ernie',
|
||||
'314159',
|
||||
)
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
||||
def test_object_create_container_public(self):
|
||||
@ -111,19 +109,13 @@ class TestContainerCreate(TestContainerAll):
|
||||
object_fakes.ENDPOINT + '/ernie',
|
||||
headers={
|
||||
'x-trans-id': '314159',
|
||||
'x-container-read': '.r:*,.rlistings'
|
||||
'x-container-read': '.r:*,.rlistings',
|
||||
},
|
||||
status_code=200,
|
||||
)
|
||||
|
||||
arglist = [
|
||||
'ernie',
|
||||
'--public'
|
||||
]
|
||||
verifylist = [
|
||||
('containers', ['ernie']),
|
||||
('public', True)
|
||||
]
|
||||
arglist = ['ernie', '--public']
|
||||
verifylist = [('containers', ['ernie']), ('public', True)]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class ShowOne in cliff, abstract method take_action()
|
||||
@ -132,11 +124,13 @@ class TestContainerCreate(TestContainerAll):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = [(
|
||||
object_fakes.ACCOUNT_ID,
|
||||
'ernie',
|
||||
'314159',
|
||||
)]
|
||||
datalist = [
|
||||
(
|
||||
object_fakes.ACCOUNT_ID,
|
||||
'ernie',
|
||||
'314159',
|
||||
)
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
||||
def test_object_create_container_more(self):
|
||||
@ -157,9 +151,12 @@ class TestContainerCreate(TestContainerAll):
|
||||
'ernie',
|
||||
'bert',
|
||||
]
|
||||
verifylist = [(
|
||||
'containers', ['ernie', 'bert'],
|
||||
)]
|
||||
verifylist = [
|
||||
(
|
||||
'containers',
|
||||
['ernie', 'bert'],
|
||||
)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class ShowOne in cliff, abstract method take_action()
|
||||
@ -184,7 +181,6 @@ class TestContainerCreate(TestContainerAll):
|
||||
|
||||
|
||||
class TestContainerDelete(TestContainerAll):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerDelete, self).setUp()
|
||||
|
||||
@ -201,9 +197,12 @@ class TestContainerDelete(TestContainerAll):
|
||||
arglist = [
|
||||
'ernie',
|
||||
]
|
||||
verifylist = [(
|
||||
'containers', ['ernie'],
|
||||
)]
|
||||
verifylist = [
|
||||
(
|
||||
'containers',
|
||||
['ernie'],
|
||||
)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# Command.take_action() returns None
|
||||
@ -226,9 +225,12 @@ class TestContainerDelete(TestContainerAll):
|
||||
'ernie',
|
||||
'bert',
|
||||
]
|
||||
verifylist = [(
|
||||
'containers', ['ernie', 'bert'],
|
||||
)]
|
||||
verifylist = [
|
||||
(
|
||||
'containers',
|
||||
['ernie', 'bert'],
|
||||
)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# Command.take_action() returns None
|
||||
@ -237,7 +239,6 @@ class TestContainerDelete(TestContainerAll):
|
||||
|
||||
|
||||
class TestContainerList(TestContainerAll):
|
||||
|
||||
columns = ('Name',)
|
||||
|
||||
def setUp(self):
|
||||
@ -268,9 +269,9 @@ class TestContainerList(TestContainerAll):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = [
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name_2, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_3,),
|
||||
(object_fakes.container_name_2,),
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
||||
@ -287,7 +288,8 @@ class TestContainerList(TestContainerAll):
|
||||
)
|
||||
|
||||
arglist = [
|
||||
'--prefix', 'bit',
|
||||
'--prefix',
|
||||
'bit',
|
||||
]
|
||||
verifylist = [
|
||||
('prefix', 'bit'),
|
||||
@ -299,20 +301,20 @@ class TestContainerList(TestContainerAll):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = [
|
||||
(object_fakes.container_name, ),
|
||||
(object_fakes.container_name_3, ),
|
||||
(object_fakes.container_name,),
|
||||
(object_fakes.container_name_3,),
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
||||
|
||||
class TestContainerSave(TestContainerAll):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerSave, self).setUp()
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = container_cmds.SaveContainer(self.app, None)
|
||||
|
||||
|
||||
# TODO(dtroyer): need to mock out object_lib.save_object() to test this
|
||||
# def test_object_save_container(self):
|
||||
# return_body = [
|
||||
@ -354,7 +356,6 @@ class TestContainerSave(TestContainerAll):
|
||||
|
||||
|
||||
class TestContainerShow(TestContainerAll):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerShow, self).setUp()
|
||||
|
||||
@ -369,7 +370,7 @@ class TestContainerShow(TestContainerAll):
|
||||
'x-container-write': 'wsx',
|
||||
'x-container-sync-to': 'edc',
|
||||
'x-container-sync-key': 'rfv',
|
||||
'x-storage-policy': 'o1--sr-r3'
|
||||
'x-storage-policy': 'o1--sr-r3',
|
||||
}
|
||||
self.requests_mock.register_uri(
|
||||
'HEAD',
|
||||
@ -381,9 +382,12 @@ class TestContainerShow(TestContainerAll):
|
||||
arglist = [
|
||||
'ernie',
|
||||
]
|
||||
verifylist = [(
|
||||
'container', 'ernie',
|
||||
)]
|
||||
verifylist = [
|
||||
(
|
||||
'container',
|
||||
'ernie',
|
||||
)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class ShowOne in cliff, abstract method take_action()
|
||||
|
@ -26,7 +26,6 @@ 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(
|
||||
@ -36,17 +35,10 @@ class TestObject(object_fakes.TestObjectv1):
|
||||
self.api = self.app.client_manager.object_store
|
||||
|
||||
|
||||
@mock.patch(
|
||||
'openstackclient.api.object_store_v1.APIv1.object_list'
|
||||
)
|
||||
@mock.patch('openstackclient.api.object_store_v1.APIv1.object_list')
|
||||
class TestObjectList(TestObject):
|
||||
|
||||
columns = ('Name',)
|
||||
datalist = (
|
||||
(
|
||||
object_fakes.object_name_2,
|
||||
),
|
||||
)
|
||||
datalist = ((object_fakes.object_name_2,),)
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectList, self).setUp()
|
||||
@ -79,8 +71,8 @@ class TestObjectList(TestObject):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.object_name_1, ),
|
||||
(object_fakes.object_name_2, ),
|
||||
(object_fakes.object_name_1,),
|
||||
(object_fakes.object_name_2,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -90,7 +82,8 @@ class TestObjectList(TestObject):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--prefix', 'floppy',
|
||||
'--prefix',
|
||||
'floppy',
|
||||
object_fakes.container_name_2,
|
||||
]
|
||||
verifylist = [
|
||||
@ -109,8 +102,7 @@ class TestObjectList(TestObject):
|
||||
'prefix': 'floppy',
|
||||
}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name_2,
|
||||
**kwargs
|
||||
container=object_fakes.container_name_2, **kwargs
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -122,7 +114,8 @@ class TestObjectList(TestObject):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--delimiter', '=',
|
||||
'--delimiter',
|
||||
'=',
|
||||
object_fakes.container_name_2,
|
||||
]
|
||||
verifylist = [
|
||||
@ -141,8 +134,7 @@ class TestObjectList(TestObject):
|
||||
'delimiter': '=',
|
||||
}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name_2,
|
||||
**kwargs
|
||||
container=object_fakes.container_name_2, **kwargs
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -154,7 +146,8 @@ class TestObjectList(TestObject):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--marker', object_fakes.object_name_2,
|
||||
'--marker',
|
||||
object_fakes.object_name_2,
|
||||
object_fakes.container_name_2,
|
||||
]
|
||||
verifylist = [
|
||||
@ -173,8 +166,7 @@ class TestObjectList(TestObject):
|
||||
'marker': object_fakes.object_name_2,
|
||||
}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name_2,
|
||||
**kwargs
|
||||
container=object_fakes.container_name_2, **kwargs
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -186,7 +178,8 @@ class TestObjectList(TestObject):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--end-marker', object_fakes.object_name_2,
|
||||
'--end-marker',
|
||||
object_fakes.object_name_2,
|
||||
object_fakes.container_name_2,
|
||||
]
|
||||
verifylist = [
|
||||
@ -205,8 +198,7 @@ class TestObjectList(TestObject):
|
||||
'end_marker': object_fakes.object_name_2,
|
||||
}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name_2,
|
||||
**kwargs
|
||||
container=object_fakes.container_name_2, **kwargs
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -218,7 +210,8 @@ class TestObjectList(TestObject):
|
||||
]
|
||||
|
||||
arglist = [
|
||||
'--limit', '2',
|
||||
'--limit',
|
||||
'2',
|
||||
object_fakes.container_name_2,
|
||||
]
|
||||
verifylist = [
|
||||
@ -237,8 +230,7 @@ class TestObjectList(TestObject):
|
||||
'limit': 2,
|
||||
}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name_2,
|
||||
**kwargs
|
||||
container=object_fakes.container_name_2, **kwargs
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -266,11 +258,9 @@ class TestObjectList(TestObject):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
}
|
||||
kwargs = {}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
**kwargs
|
||||
container=object_fakes.container_name, **kwargs
|
||||
)
|
||||
|
||||
collist = ('Name', 'Bytes', 'Hash', 'Content Type', 'Last Modified')
|
||||
@ -319,23 +309,19 @@ class TestObjectList(TestObject):
|
||||
'full_listing': True,
|
||||
}
|
||||
o_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
**kwargs
|
||||
container=object_fakes.container_name, **kwargs
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.object_name_1, ),
|
||||
(object_fakes.object_name_2, ),
|
||||
(object_fakes.object_name_1,),
|
||||
(object_fakes.object_name_2,),
|
||||
)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
||||
@mock.patch(
|
||||
'openstackclient.api.object_store_v1.APIv1.object_show'
|
||||
)
|
||||
@mock.patch('openstackclient.api.object_store_v1.APIv1.object_show')
|
||||
class TestObjectShow(TestObject):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectShow, self).setUp()
|
||||
|
||||
@ -361,8 +347,7 @@ class TestObjectShow(TestObject):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
}
|
||||
kwargs = {}
|
||||
# lib.container.show_container(api, url, container)
|
||||
c_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
|
@ -23,7 +23,6 @@ from openstackclient.tests.unit.object.v1 import fakes as object_fakes
|
||||
|
||||
|
||||
class TestObjectAll(object_fakes.TestObjectv1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectAll, self).setUp()
|
||||
|
||||
@ -31,7 +30,6 @@ class TestObjectAll(object_fakes.TestObjectv1):
|
||||
|
||||
|
||||
class TestObjectCreate(TestObjectAll):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectCreate, self).setUp()
|
||||
|
||||
@ -43,25 +41,27 @@ class TestObjectCreate(TestObjectAll):
|
||||
object_fakes.container_name,
|
||||
object_fakes.object_name_1,
|
||||
object_fakes.object_name_2,
|
||||
'--name', object_fakes.object_upload_name,
|
||||
'--name',
|
||||
object_fakes.object_upload_name,
|
||||
]
|
||||
|
||||
verifylist = [
|
||||
('container', object_fakes.container_name),
|
||||
('objects', [object_fakes.object_name_1,
|
||||
object_fakes.object_name_2]),
|
||||
(
|
||||
'objects',
|
||||
[object_fakes.object_name_1, object_fakes.object_name_2],
|
||||
),
|
||||
('name', object_fakes.object_upload_name),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
self.assertRaises(
|
||||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||
)
|
||||
|
||||
|
||||
class TestObjectList(TestObjectAll):
|
||||
|
||||
columns = ('Name',)
|
||||
|
||||
def setUp(self):
|
||||
@ -77,10 +77,10 @@ class TestObjectList(TestObjectAll):
|
||||
]
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
object_fakes.ENDPOINT +
|
||||
'/' +
|
||||
object_fakes.container_name +
|
||||
'?format=json',
|
||||
object_fakes.ENDPOINT
|
||||
+ '/'
|
||||
+ object_fakes.container_name
|
||||
+ '?format=json',
|
||||
json=return_body,
|
||||
status_code=200,
|
||||
)
|
||||
@ -98,8 +98,8 @@ class TestObjectList(TestObjectAll):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = [
|
||||
(object_fakes.object_name_1, ),
|
||||
(object_fakes.object_name_2, ),
|
||||
(object_fakes.object_name_1,),
|
||||
(object_fakes.object_name_2,),
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
||||
@ -109,16 +109,17 @@ class TestObjectList(TestObjectAll):
|
||||
]
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
object_fakes.ENDPOINT +
|
||||
'/' +
|
||||
object_fakes.container_name_2 +
|
||||
'?prefix=floppy&format=json',
|
||||
object_fakes.ENDPOINT
|
||||
+ '/'
|
||||
+ object_fakes.container_name_2
|
||||
+ '?prefix=floppy&format=json',
|
||||
json=return_body,
|
||||
status_code=200,
|
||||
)
|
||||
|
||||
arglist = [
|
||||
'--prefix', 'floppy',
|
||||
'--prefix',
|
||||
'floppy',
|
||||
object_fakes.container_name_2,
|
||||
]
|
||||
verifylist = [
|
||||
@ -133,14 +134,11 @@ class TestObjectList(TestObjectAll):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
(object_fakes.object_name_2, ),
|
||||
)
|
||||
datalist = ((object_fakes.object_name_2,),)
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
||||
class TestObjectShow(TestObjectAll):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectShow, self).setUp()
|
||||
|
||||
@ -158,11 +156,13 @@ class TestObjectShow(TestObjectAll):
|
||||
}
|
||||
self.requests_mock.register_uri(
|
||||
'HEAD',
|
||||
'/'.join([
|
||||
object_fakes.ENDPOINT,
|
||||
object_fakes.container_name,
|
||||
object_fakes.object_name_1,
|
||||
]),
|
||||
'/'.join(
|
||||
[
|
||||
object_fakes.ENDPOINT,
|
||||
object_fakes.container_name,
|
||||
object_fakes.object_name_1,
|
||||
]
|
||||
),
|
||||
headers=headers,
|
||||
status_code=200,
|
||||
)
|
||||
@ -207,7 +207,6 @@ class TestObjectShow(TestObjectAll):
|
||||
|
||||
|
||||
class TestObjectSave(TestObjectAll):
|
||||
|
||||
def setUp(self):
|
||||
super(TestObjectSave, self).setUp()
|
||||
|
||||
@ -217,20 +216,20 @@ class TestObjectSave(TestObjectAll):
|
||||
def test_save_to_stdout(self):
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
object_fakes.ENDPOINT +
|
||||
'/' +
|
||||
object_fakes.container_name +
|
||||
'/' +
|
||||
object_fakes.object_name_1,
|
||||
object_fakes.ENDPOINT
|
||||
+ '/'
|
||||
+ object_fakes.container_name
|
||||
+ '/'
|
||||
+ object_fakes.object_name_1,
|
||||
status_code=200,
|
||||
content=object_fakes.object_1_content
|
||||
content=object_fakes.object_1_content,
|
||||
)
|
||||
|
||||
arglist = [
|
||||
object_fakes.container_name,
|
||||
object_fakes.object_name_1,
|
||||
'--file',
|
||||
'-'
|
||||
'-',
|
||||
]
|
||||
|
||||
verifylist = [
|
||||
@ -254,12 +253,16 @@ class TestObjectSave(TestObjectAll):
|
||||
self.context_manager_calls.append('__exit__')
|
||||
|
||||
with mock.patch('sys.stdout') as fake_stdout, mock.patch(
|
||||
'os.fdopen', return_value=FakeStdout()) as fake_fdopen:
|
||||
'os.fdopen', return_value=FakeStdout()
|
||||
) as fake_fdopen:
|
||||
fake_stdout.fileno.return_value = 123
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(fake_fdopen.return_value.getvalue(),
|
||||
object_fakes.object_1_content)
|
||||
self.assertEqual(
|
||||
fake_fdopen.return_value.getvalue(), object_fakes.object_1_content
|
||||
)
|
||||
self.assertEqual(fake_fdopen.mock_calls, [mock.call(123, 'wb')])
|
||||
self.assertEqual(fake_fdopen.return_value.context_manager_calls,
|
||||
['__enter__', '__exit__'])
|
||||
self.assertEqual(
|
||||
fake_fdopen.return_value.context_manager_calls,
|
||||
['__enter__', '__exit__'],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user