diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2013-08-30 17:55:37 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2013-09-26 13:34:11 -0500 |
| commit | ad59b03be6af9da31230689af268139b12b548e7 (patch) | |
| tree | 0394d365ab2b1d847ae20f46b0c208a71e5dd9a3 /openstackclient/tests/object/v1/lib/test_object.py | |
| parent | 74f4e3138996e258d4bdce1a162a5dade62a0c15 (diff) | |
| download | python-openstackclient-ad59b03be6af9da31230689af268139b12b548e7.tar.gz | |
Add object-store show commands
* Add lib.container.show_container() and lib.object.show_object()
* Add container and object show commands
Change-Id: I963d664c55b59739453345f0f353aa2eaf1bf70e
Diffstat (limited to 'openstackclient/tests/object/v1/lib/test_object.py')
| -rw-r--r-- | openstackclient/tests/object/v1/lib/test_object.py | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/openstackclient/tests/object/v1/lib/test_object.py b/openstackclient/tests/object/v1/lib/test_object.py index b4793cc2..0104183e 100644 --- a/openstackclient/tests/object/v1/lib/test_object.py +++ b/openstackclient/tests/object/v1/lib/test_object.py @@ -15,8 +15,6 @@ """Test Object API library module""" -from __future__ import unicode_literals - import mock from openstackclient.object.v1.lib import object as lib_object @@ -25,10 +23,12 @@ from openstackclient.tests import fakes from openstackclient.tests import utils +fake_account = 'q12we34r' fake_auth = '11223344556677889900' -fake_url = 'http://gopher.com' +fake_url = 'http://gopher.com/v1/' + fake_account fake_container = 'rainbarrel' +fake_object = 'raindrop' class FakeClient(object): @@ -203,3 +203,74 @@ class TestObjectListObjects(TestObject): fake_url + '/' + fake_container + '?format=json&marker=is-name', ) self.assertEqual(data, resp) + + +class TestObjectShowObjects(TestObject): + + def test_object_show_no_options(self): + resp = { + 'content-type': 'text/alpha', + } + self.app.restapi.request.return_value = \ + restapi.FakeResponse(headers=resp) + + data = lib_object.show_object( + self.app.restapi, + self.app.client_manager.object.endpoint, + fake_container, + fake_object, + ) + + # Check expected values + self.app.restapi.request.assert_called_with( + 'HEAD', + fake_url + '/%s/%s' % (fake_container, fake_object), + ) + + data_expected = { + 'account': fake_account, + 'container': fake_container, + 'object': fake_object, + 'content-type': 'text/alpha', + } + self.assertEqual(data, data_expected) + + def test_object_show_all_options(self): + resp = { + 'content-type': 'text/alpha', + 'content-length': 577, + 'last-modified': '20130101', + 'etag': 'qaz', + 'x-object-manifest': None, + 'x-object-meta-wife': 'Wilma', + 'x-tra-header': 'yabba-dabba-do', + } + self.app.restapi.request.return_value = \ + restapi.FakeResponse(headers=resp) + + data = lib_object.show_object( + self.app.restapi, + self.app.client_manager.object.endpoint, + fake_container, + fake_object, + ) + + # Check expected values + self.app.restapi.request.assert_called_with( + 'HEAD', + fake_url + '/%s/%s' % (fake_container, fake_object), + ) + + data_expected = { + 'account': fake_account, + 'container': fake_container, + 'object': fake_object, + 'content-type': 'text/alpha', + 'content-length': 577, + 'last-modified': '20130101', + 'etag': 'qaz', + 'x-object-manifest': None, + 'Wife': 'Wilma', + 'X-Tra-Header': 'yabba-dabba-do', + } + self.assertEqual(data, data_expected) |
