Merge "glance-replicator: size: Handle no args better"
This commit is contained in:
commit
5f6dc003ae
@ -330,7 +330,7 @@ def replication_size(options, args):
|
||||
"""
|
||||
|
||||
# Make sure server info is provided
|
||||
if len(args) < 1:
|
||||
if args is None or len(args) < 1:
|
||||
raise TypeError(_("Too few arguments."))
|
||||
|
||||
server, port = utils.parse_valid_host_port(args.pop())
|
||||
|
@ -310,8 +310,9 @@ def check_no_args(command, args):
|
||||
try:
|
||||
glance_replicator.get_image_service = get_image_service
|
||||
command(options, args)
|
||||
except TypeError:
|
||||
no_args_error = True
|
||||
except TypeError as e:
|
||||
if str(e) == "Too few arguments.":
|
||||
no_args_error = True
|
||||
finally:
|
||||
glance_replicator.get_image_service = orig_img_service
|
||||
|
||||
@ -374,6 +375,11 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
||||
command = glance_replicator.replication_size
|
||||
self.assertTrue(check_no_args(command, args))
|
||||
|
||||
def test_replication_size_with_args_is_None(self):
|
||||
args = None
|
||||
command = glance_replicator.replication_size
|
||||
self.assertTrue(check_no_args(command, args))
|
||||
|
||||
def test_replication_size_with_bad_args(self):
|
||||
args = ['aaa']
|
||||
command = glance_replicator.replication_size
|
||||
|
Loading…
Reference in New Issue
Block a user