summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorRajasi Kulkarni <rajasikulkarni18@gmail.com>2016-08-22 00:26:46 +0530
committerSteve Martinelli <s.martinelli@gmail.com>2016-09-26 22:42:10 -0400
commit78312ca9afea22f6511f2421dccb0736f394e9c8 (patch)
treea642188484c98b61a01ec6483d80b14dc4b519dd /openstackclient/tests
parentf19240fc29c542726acd11a7f71f307be219695f (diff)
downloadpython-openstackclient-78312ca9afea22f6511f2421dccb0736f394e9c8.tar.gz
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
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/unit/object/v1/fakes.py2
-rw-r--r--openstackclient/tests/unit/object/v1/test_object_all.py22
2 files changed, 24 insertions, 0 deletions
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):