From 78312ca9afea22f6511f2421dccb0736f394e9c8 Mon Sep 17 00:00:00 2001 From: Rajasi Kulkarni Date: Mon, 22 Aug 2016 00:26:46 +0530 Subject: Add option "--name" to command "openstack object create" Option "--name" can be used to set as the object name of the file to be uploaded in the container. Similar to option "--object-name" in command "swift upload". Added unit test case to ensure an exception is raised when using option "--name" for uploading multiple objects. Change-Id: Ied7827841f6ca1cf9d4b48e304cbe5d62eda38ab Closes-Bug: #1607972 --- openstackclient/tests/unit/object/v1/fakes.py | 2 ++ .../tests/unit/object/v1/test_object_all.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'openstackclient/tests/unit/object') diff --git a/openstackclient/tests/unit/object/v1/fakes.py b/openstackclient/tests/unit/object/v1/fakes.py index 0ff594bc..72646d25 100644 --- a/openstackclient/tests/unit/object/v1/fakes.py +++ b/openstackclient/tests/unit/object/v1/fakes.py @@ -75,6 +75,8 @@ OBJECT_2 = { 'last_modified': object_modified_2, } +object_upload_name = 'test-object-name' + class TestObjectv1(utils.TestCommand): diff --git a/openstackclient/tests/unit/object/v1/test_object_all.py b/openstackclient/tests/unit/object/v1/test_object_all.py index a0948b1b..f215836e 100644 --- a/openstackclient/tests/unit/object/v1/test_object_all.py +++ b/openstackclient/tests/unit/object/v1/test_object_all.py @@ -13,6 +13,7 @@ import copy +from osc_lib import exceptions from requests_mock.contrib import fixture from openstackclient.object.v1 import object as object_cmds @@ -35,6 +36,27 @@ class TestObjectCreate(TestObjectAll): # Get the command object to test self.cmd = object_cmds.CreateObject(self.app, None) + def test_multiple_object_create_with_object_name(self): + arglist = [ + object_fakes.container_name, + object_fakes.object_name_1, + object_fakes.object_name_2, + '--name', object_fakes.object_upload_name, + ] + + verifylist = [ + ('container', object_fakes.container_name), + ('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) + class TestObjectList(TestObjectAll): -- cgit v1.2.1