summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/object/v1
diff options
context:
space:
mode:
authorSimon Merrick <simonmerrick@catalyst.net.nz>2020-02-18 12:48:02 +1300
committerSimon Merrick <simonmerrick@catalyst.net.nz>2020-02-19 10:08:48 +1300
commitd6022f96dfd608b83a4ff41483336f024aeacb16 (patch)
tree6725370f16ff067e6dc7bbbfbb6aa2bfd683e778 /openstackclient/tests/unit/object/v1
parente07324e30fbb24e89fd63d1c5a5fe485f693a45c (diff)
downloadpython-openstackclient-d6022f96dfd608b83a4ff41483336f024aeacb16.tar.gz
Add storage policy option to create container command
+ Add CLI option to specify swift storage policy + Add CLI flag to specify container uses public read ACLS + Show storage policy in container show data Change-Id: I08ffa0d98bd39d467aa415771675f59bd77768ff
Diffstat (limited to 'openstackclient/tests/unit/object/v1')
-rw-r--r--openstackclient/tests/unit/object/v1/test_container_all.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/object/v1/test_container_all.py b/openstackclient/tests/unit/object/v1/test_container_all.py
index 58c90e36..654cfbc7 100644
--- a/openstackclient/tests/unit/object/v1/test_container_all.py
+++ b/openstackclient/tests/unit/object/v1/test_container_all.py
@@ -70,6 +70,75 @@ class TestContainerCreate(TestContainerAll):
)]
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'
+ },
+ status_code=200,
+ )
+
+ arglist = [
+ 'ernie',
+ '--storage-policy',
+ 'o1--sr-r3'
+ ]
+ verifylist = [
+ ('containers', ['ernie']),
+ ('storage_policy', 'o1--sr-r3')
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # In base command class ShowOne in cliff, abstract method take_action()
+ # returns a two-part tuple with a tuple of column names and a tuple of
+ # data to be shown.
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.assertEqual(self.columns, columns)
+ datalist = [(
+ object_fakes.ACCOUNT_ID,
+ 'ernie',
+ '314159',
+ )]
+ self.assertEqual(datalist, list(data))
+
+ def test_object_create_container_public(self):
+ self.requests_mock.register_uri(
+ 'PUT',
+ object_fakes.ENDPOINT + '/ernie',
+ headers={
+ 'x-trans-id': '314159',
+ 'x-container-read': '.r:*,.rlistings'
+ },
+ status_code=200,
+ )
+
+ 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()
+ # returns a two-part tuple with a tuple of column names and a tuple of
+ # data to be shown.
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.assertEqual(self.columns, columns)
+ datalist = [(
+ object_fakes.ACCOUNT_ID,
+ 'ernie',
+ '314159',
+ )]
+ self.assertEqual(datalist, list(data))
+
def test_object_create_container_more(self):
self.requests_mock.register_uri(
'PUT',
@@ -300,6 +369,7 @@ class TestContainerShow(TestContainerAll):
'x-container-write': 'wsx',
'x-container-sync-to': 'edc',
'x-container-sync-key': 'rfv',
+ 'x-storage-policy': 'o1--sr-r3'
}
self.requests_mock.register_uri(
'HEAD',
@@ -327,6 +397,7 @@ class TestContainerShow(TestContainerAll):
'container',
'object_count',
'read_acl',
+ 'storage_policy',
'sync_key',
'sync_to',
'write_acl',
@@ -338,6 +409,7 @@ class TestContainerShow(TestContainerAll):
'ernie',
'42',
'qaz',
+ 'o1--sr-r3',
'rfv',
'edc',
'wsx',