|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +import uuid |
| 14 | + |
| 15 | +from functional.common import test |
| 16 | + |
| 17 | +BASIC_LIST_HEADERS = ['Name'] |
| 18 | +CONTAINER_FIELDS = ['account', 'container', 'x-trans-id'] |
| 19 | +OBJECT_FIELDS = ['object', 'container', 'etag'] |
| 20 | + |
| 21 | + |
| 22 | +class ObjectV1Tests(test.TestCase): |
| 23 | + """Functional tests for Object V1 commands. """ |
| 24 | + |
| 25 | + CONTAINER_NAME = uuid.uuid4().hex |
| 26 | + OBJECT_NAME = uuid.uuid4().hex |
| 27 | + |
| 28 | + # NOTE(stevemar): Not using setUp since we only want this to run once |
| 29 | + with open(OBJECT_NAME, 'w') as f: |
| 30 | + f.write('test content') |
| 31 | + |
| 32 | + def test_container_create(self): |
| 33 | + raw_output = self.openstack('container create ' + self.CONTAINER_NAME) |
| 34 | + items = self.parse_listing(raw_output) |
| 35 | + self.assert_show_fields(items, CONTAINER_FIELDS) |
| 36 | + |
| 37 | + def test_container_delete(self): |
| 38 | + container_tmp = uuid.uuid4().hex |
| 39 | + self.openstack('container create ' + container_tmp) |
| 40 | + raw_output = self.openstack('container delete ' + container_tmp) |
| 41 | + self.assertEqual(0, len(raw_output)) |
| 42 | + |
| 43 | + def test_container_list(self): |
| 44 | + raw_output = self.openstack('container list') |
| 45 | + items = self.parse_listing(raw_output) |
| 46 | + self.assert_table_structure(items, BASIC_LIST_HEADERS) |
| 47 | + |
| 48 | + def test_container_show(self): |
| 49 | + self.openstack('container show ' + self.CONTAINER_NAME) |
| 50 | + # TODO(stevemar): Assert returned fields |
| 51 | + |
| 52 | + def test_container_save(self): |
| 53 | + self.openstack('container save ' + self.CONTAINER_NAME) |
| 54 | + # TODO(stevemar): Assert returned fields |
| 55 | + |
| 56 | + def test_object_create(self): |
| 57 | + raw_output = self.openstack('object create ' + self.CONTAINER_NAME |
| 58 | + + ' ' + self.OBJECT_NAME) |
| 59 | + items = self.parse_listing(raw_output) |
| 60 | + self.assert_show_fields(items, OBJECT_FIELDS) |
| 61 | + |
| 62 | + def test_object_delete(self): |
| 63 | + raw_output = self.openstack('object delete ' + self.CONTAINER_NAME |
| 64 | + + ' ' + self.OBJECT_NAME) |
| 65 | + self.assertEqual(0, len(raw_output)) |
| 66 | + |
| 67 | + def test_object_list(self): |
| 68 | + raw_output = self.openstack('object list ' + self.CONTAINER_NAME) |
| 69 | + items = self.parse_listing(raw_output) |
| 70 | + self.assert_table_structure(items, BASIC_LIST_HEADERS) |
| 71 | + |
| 72 | + def test_object_save(self): |
| 73 | + self.openstack('object create ' + self.CONTAINER_NAME |
| 74 | + + ' ' + self.OBJECT_NAME) |
| 75 | + self.openstack('object save ' + self.CONTAINER_NAME |
| 76 | + + ' ' + self.OBJECT_NAME) |
| 77 | + # TODO(stevemar): Assert returned fields |
| 78 | + |
| 79 | + def test_object_save_with_filename(self): |
| 80 | + self.openstack('object create ' + self.CONTAINER_NAME |
| 81 | + + ' ' + self.OBJECT_NAME) |
| 82 | + self.openstack('object save ' + self.CONTAINER_NAME |
| 83 | + + ' ' + self.OBJECT_NAME + ' --file tmp.txt') |
| 84 | + # TODO(stevemar): Assert returned fields |
| 85 | + |
| 86 | + def test_object_show(self): |
| 87 | + self.openstack('object create ' + self.CONTAINER_NAME |
| 88 | + + ' ' + self.OBJECT_NAME) |
| 89 | + self.openstack('object show ' + self.CONTAINER_NAME |
| 90 | + + ' ' + self.OBJECT_NAME) |
| 91 | + # TODO(stevemar): Assert returned fields |
0 commit comments