Merge "Beef up object-store tests"
This commit is contained in:
commit
c55fdb6f6d
@ -13,7 +13,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from openstackclient.tests import fakes
|
from keystoneclient import session
|
||||||
|
from openstackclient.api import object_store_v1 as object_store
|
||||||
from openstackclient.tests import utils
|
from openstackclient.tests import utils
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +79,8 @@ class TestObjectv1(utils.TestCommand):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestObjectv1, self).setUp()
|
super(TestObjectv1, self).setUp()
|
||||||
|
|
||||||
self.app.client_manager.object_store = fakes.FakeClient(
|
self.app.client_manager.session = session.Session()
|
||||||
endpoint=fakes.AUTH_URL,
|
self.app.client_manager.object_store = object_store.APIv1(
|
||||||
token=fakes.AUTH_TOKEN,
|
session=self.app.client_manager.session,
|
||||||
|
endpoint=ENDPOINT,
|
||||||
)
|
)
|
||||||
|
@ -74,13 +74,13 @@ class TestContainerList(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.container_name, ),
|
(object_fakes.container_name, ),
|
||||||
(object_fakes.container_name_3, ),
|
(object_fakes.container_name_3, ),
|
||||||
(object_fakes.container_name_2, ),
|
(object_fakes.container_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_containers_prefix(self, c_mock):
|
def test_object_list_containers_prefix(self, c_mock):
|
||||||
c_mock.return_value = [
|
c_mock.return_value = [
|
||||||
@ -108,12 +108,12 @@ class TestContainerList(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.container_name, ),
|
(object_fakes.container_name, ),
|
||||||
(object_fakes.container_name_3, ),
|
(object_fakes.container_name_3, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_containers_marker(self, c_mock):
|
def test_object_list_containers_marker(self, c_mock):
|
||||||
c_mock.return_value = [
|
c_mock.return_value = [
|
||||||
@ -144,12 +144,12 @@ class TestContainerList(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.container_name, ),
|
(object_fakes.container_name, ),
|
||||||
(object_fakes.container_name_3, ),
|
(object_fakes.container_name_3, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_containers_limit(self, c_mock):
|
def test_object_list_containers_limit(self, c_mock):
|
||||||
c_mock.return_value = [
|
c_mock.return_value = [
|
||||||
@ -177,12 +177,12 @@ class TestContainerList(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.container_name, ),
|
(object_fakes.container_name, ),
|
||||||
(object_fakes.container_name_3, ),
|
(object_fakes.container_name_3, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_containers_long(self, c_mock):
|
def test_object_list_containers_long(self, c_mock):
|
||||||
c_mock.return_value = [
|
c_mock.return_value = [
|
||||||
@ -209,7 +209,7 @@ class TestContainerList(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name', 'Bytes', 'Count')
|
collist = ('Name', 'Bytes', 'Count')
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(
|
(
|
||||||
object_fakes.container_name,
|
object_fakes.container_name,
|
||||||
@ -222,7 +222,7 @@ class TestContainerList(TestContainer):
|
|||||||
object_fakes.container_count * 3,
|
object_fakes.container_count * 3,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_containers_all(self, c_mock):
|
def test_object_list_containers_all(self, c_mock):
|
||||||
c_mock.return_value = [
|
c_mock.return_value = [
|
||||||
@ -251,13 +251,13 @@ class TestContainerList(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.container_name, ),
|
(object_fakes.container_name, ),
|
||||||
(object_fakes.container_name_2, ),
|
(object_fakes.container_name_2, ),
|
||||||
(object_fakes.container_name_3, ),
|
(object_fakes.container_name_3, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
|
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
@ -295,10 +295,10 @@ class TestContainerShow(TestContainer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('bytes', 'count', 'name')
|
collist = ('bytes', 'count', 'name')
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
object_fakes.container_bytes,
|
object_fakes.container_bytes,
|
||||||
object_fakes.container_count,
|
object_fakes.container_count,
|
||||||
object_fakes.container_name,
|
object_fakes.container_name,
|
||||||
)
|
)
|
||||||
self.assertEqual(data, datalist)
|
self.assertEqual(datalist, data)
|
||||||
|
@ -15,34 +15,25 @@ import copy
|
|||||||
|
|
||||||
from requests_mock.contrib import fixture
|
from requests_mock.contrib import fixture
|
||||||
|
|
||||||
from keystoneclient import session
|
from openstackclient.object.v1 import container as container_cmds
|
||||||
from openstackclient.api import object_store_v1 as object_store
|
|
||||||
from openstackclient.object.v1 import container
|
|
||||||
from openstackclient.tests.object.v1 import fakes as object_fakes
|
from openstackclient.tests.object.v1 import fakes as object_fakes
|
||||||
|
|
||||||
|
|
||||||
class TestObjectAll(object_fakes.TestObjectv1):
|
class TestContainerAll(object_fakes.TestObjectv1):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestObjectAll, self).setUp()
|
super(TestContainerAll, self).setUp()
|
||||||
|
|
||||||
self.app.client_manager.session = session.Session()
|
|
||||||
self.requests_mock = self.useFixture(fixture.Fixture())
|
self.requests_mock = self.useFixture(fixture.Fixture())
|
||||||
|
|
||||||
# TODO(dtroyer): move this to object_fakes.TestObjectv1
|
|
||||||
self.app.client_manager.object_store = object_store.APIv1(
|
|
||||||
session=self.app.client_manager.session,
|
|
||||||
endpoint=object_fakes.ENDPOINT,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
class TestContainerCreate(TestContainerAll):
|
||||||
class TestContainerCreate(TestObjectAll):
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContainerCreate, self).setUp()
|
super(TestContainerCreate, self).setUp()
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container.CreateContainer(self.app, None)
|
self.cmd = container_cmds.CreateContainer(self.app, None)
|
||||||
|
|
||||||
def test_object_create_container_single(self):
|
def test_object_create_container_single(self):
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
@ -115,13 +106,13 @@ class TestContainerCreate(TestObjectAll):
|
|||||||
self.assertEqual(datalist, list(data))
|
self.assertEqual(datalist, list(data))
|
||||||
|
|
||||||
|
|
||||||
class TestContainerDelete(TestObjectAll):
|
class TestContainerDelete(TestContainerAll):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContainerDelete, self).setUp()
|
super(TestContainerDelete, self).setUp()
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container.DeleteContainer(self.app, None)
|
self.cmd = container_cmds.DeleteContainer(self.app, None)
|
||||||
|
|
||||||
def test_object_delete_container_single(self):
|
def test_object_delete_container_single(self):
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
@ -168,13 +159,13 @@ class TestContainerDelete(TestObjectAll):
|
|||||||
self.assertIsNone(ret)
|
self.assertIsNone(ret)
|
||||||
|
|
||||||
|
|
||||||
class TestContainerList(TestObjectAll):
|
class TestContainerList(TestContainerAll):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContainerList, self).setUp()
|
super(TestContainerList, self).setUp()
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container.ListContainer(self.app, None)
|
self.cmd = container_cmds.ListContainer(self.app, None)
|
||||||
|
|
||||||
def test_object_list_containers_no_options(self):
|
def test_object_list_containers_no_options(self):
|
||||||
return_body = [
|
return_body = [
|
||||||
@ -237,13 +228,13 @@ class TestContainerList(TestObjectAll):
|
|||||||
self.assertEqual(datalist, list(data))
|
self.assertEqual(datalist, list(data))
|
||||||
|
|
||||||
|
|
||||||
class TestContainerSave(TestObjectAll):
|
class TestContainerSave(TestContainerAll):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContainerSave, self).setUp()
|
super(TestContainerSave, self).setUp()
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container.SaveContainer(self.app, None)
|
self.cmd = container_cmds.SaveContainer(self.app, None)
|
||||||
|
|
||||||
# TODO(dtroyer): need to mock out object_lib.save_object() to test this
|
# TODO(dtroyer): need to mock out object_lib.save_object() to test this
|
||||||
# def test_object_save_container(self):
|
# def test_object_save_container(self):
|
||||||
@ -285,13 +276,13 @@ class TestContainerSave(TestObjectAll):
|
|||||||
# self.assertIsNone(ret)
|
# self.assertIsNone(ret)
|
||||||
|
|
||||||
|
|
||||||
class TestContainerShow(TestObjectAll):
|
class TestContainerShow(TestContainerAll):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContainerShow, self).setUp()
|
super(TestContainerShow, self).setUp()
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container.ShowContainer(self.app, None)
|
self.cmd = container_cmds.ShowContainer(self.app, None)
|
||||||
|
|
||||||
def test_object_show_container(self):
|
def test_object_show_container(self):
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -68,12 +68,12 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_1, ),
|
(object_fakes.object_name_1, ),
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_prefix(self, o_mock):
|
def test_object_list_objects_prefix(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -103,11 +103,11 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_delimiter(self, o_mock):
|
def test_object_list_objects_delimiter(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -137,11 +137,11 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_marker(self, o_mock):
|
def test_object_list_objects_marker(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -171,11 +171,11 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_end_marker(self, o_mock):
|
def test_object_list_objects_end_marker(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -205,11 +205,11 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_limit(self, o_mock):
|
def test_object_list_objects_limit(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -239,11 +239,11 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_long(self, o_mock):
|
def test_object_list_objects_long(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -273,7 +273,7 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name', 'Bytes', 'Hash', 'Content Type', 'Last Modified')
|
collist = ('Name', 'Bytes', 'Hash', 'Content Type', 'Last Modified')
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(
|
(
|
||||||
object_fakes.object_name_1,
|
object_fakes.object_name_1,
|
||||||
@ -290,7 +290,7 @@ class TestObjectList(TestObject):
|
|||||||
object_fakes.object_modified_2,
|
object_fakes.object_modified_2,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_object_list_objects_all(self, o_mock):
|
def test_object_list_objects_all(self, o_mock):
|
||||||
o_mock.return_value = [
|
o_mock.return_value = [
|
||||||
@ -321,12 +321,12 @@ class TestObjectList(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('Name',)
|
collist = ('Name',)
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
(object_fakes.object_name_1, ),
|
(object_fakes.object_name_1, ),
|
||||||
(object_fakes.object_name_2, ),
|
(object_fakes.object_name_2, ),
|
||||||
)
|
)
|
||||||
self.assertEqual(tuple(data), datalist)
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
|
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
@ -367,7 +367,7 @@ class TestObjectShow(TestObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
collist = ('bytes', 'content_type', 'hash', 'last_modified', 'name')
|
collist = ('bytes', 'content_type', 'hash', 'last_modified', 'name')
|
||||||
self.assertEqual(columns, collist)
|
self.assertEqual(collist, columns)
|
||||||
datalist = (
|
datalist = (
|
||||||
object_fakes.object_bytes_1,
|
object_fakes.object_bytes_1,
|
||||||
object_fakes.object_content_type_1,
|
object_fakes.object_content_type_1,
|
||||||
@ -375,4 +375,4 @@ class TestObjectShow(TestObject):
|
|||||||
object_fakes.object_modified_1,
|
object_fakes.object_modified_1,
|
||||||
object_fakes.object_name_1,
|
object_fakes.object_name_1,
|
||||||
)
|
)
|
||||||
self.assertEqual(data, datalist)
|
self.assertEqual(datalist, data)
|
||||||
|
177
openstackclient/tests/object/v1/test_object_all.py
Normal file
177
openstackclient/tests/object/v1/test_object_all.py
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from requests_mock.contrib import fixture
|
||||||
|
|
||||||
|
from openstackclient.object.v1 import object as object_cmds
|
||||||
|
from openstackclient.tests.object.v1 import fakes as object_fakes
|
||||||
|
|
||||||
|
|
||||||
|
class TestObjectAll(object_fakes.TestObjectv1):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestObjectAll, self).setUp()
|
||||||
|
|
||||||
|
self.requests_mock = self.useFixture(fixture.Fixture())
|
||||||
|
|
||||||
|
|
||||||
|
class TestObjectCreate(TestObjectAll):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestObjectCreate, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = object_cmds.CreateObject(self.app, None)
|
||||||
|
|
||||||
|
|
||||||
|
class TestObjectList(TestObjectAll):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestObjectList, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = object_cmds.ListObject(self.app, None)
|
||||||
|
|
||||||
|
def test_object_list_objects_no_options(self):
|
||||||
|
return_body = [
|
||||||
|
copy.deepcopy(object_fakes.OBJECT),
|
||||||
|
copy.deepcopy(object_fakes.OBJECT_2),
|
||||||
|
]
|
||||||
|
self.requests_mock.register_uri(
|
||||||
|
'GET',
|
||||||
|
object_fakes.ENDPOINT +
|
||||||
|
'/' +
|
||||||
|
object_fakes.container_name +
|
||||||
|
'?format=json',
|
||||||
|
json=return_body,
|
||||||
|
status_code=200,
|
||||||
|
)
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
object_fakes.container_name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('container', object_fakes.container_name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
# Lister.take_action() returns two tuples
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
collist = ('Name',)
|
||||||
|
self.assertEqual(collist, columns)
|
||||||
|
datalist = [
|
||||||
|
(object_fakes.object_name_1, ),
|
||||||
|
(object_fakes.object_name_2, ),
|
||||||
|
]
|
||||||
|
self.assertEqual(datalist, list(data))
|
||||||
|
|
||||||
|
def test_object_list_objects_prefix(self):
|
||||||
|
return_body = [
|
||||||
|
copy.deepcopy(object_fakes.OBJECT_2),
|
||||||
|
]
|
||||||
|
self.requests_mock.register_uri(
|
||||||
|
'GET',
|
||||||
|
object_fakes.ENDPOINT +
|
||||||
|
'/' +
|
||||||
|
object_fakes.container_name_2 +
|
||||||
|
'?prefix=floppy&format=json',
|
||||||
|
json=return_body,
|
||||||
|
status_code=200,
|
||||||
|
)
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
'--prefix', 'floppy',
|
||||||
|
object_fakes.container_name_2,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('prefix', 'floppy'),
|
||||||
|
('container', object_fakes.container_name_2),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
# DisplayCommandBase.take_action() returns two tuples
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
collist = ('Name',)
|
||||||
|
self.assertEqual(columns, collist)
|
||||||
|
datalist = (
|
||||||
|
(object_fakes.object_name_2, ),
|
||||||
|
)
|
||||||
|
self.assertEqual(tuple(data), datalist)
|
||||||
|
|
||||||
|
|
||||||
|
class TestObjectShow(TestObjectAll):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestObjectShow, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = object_cmds.ShowObject(self.app, None)
|
||||||
|
|
||||||
|
def test_object_show(self):
|
||||||
|
headers = {
|
||||||
|
'content-type': 'text/plain',
|
||||||
|
'content-length': '20',
|
||||||
|
'last-modified': 'yesterday',
|
||||||
|
'etag': '4c4e39a763d58392724bccf76a58783a',
|
||||||
|
'x-container-meta-owner': object_fakes.ACCOUNT_ID,
|
||||||
|
'x-object-manifest': 'manifest',
|
||||||
|
}
|
||||||
|
self.requests_mock.register_uri(
|
||||||
|
'HEAD',
|
||||||
|
'/'.join([
|
||||||
|
object_fakes.ENDPOINT,
|
||||||
|
object_fakes.container_name,
|
||||||
|
object_fakes.object_name_1,
|
||||||
|
]),
|
||||||
|
headers=headers,
|
||||||
|
status_code=200,
|
||||||
|
)
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
object_fakes.container_name,
|
||||||
|
object_fakes.object_name_1,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('container', object_fakes.container_name),
|
||||||
|
('object', object_fakes.object_name_1),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
# DisplayCommandBase.take_action() returns two tuples
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
collist = (
|
||||||
|
'account',
|
||||||
|
'container',
|
||||||
|
'content-length',
|
||||||
|
'content-type',
|
||||||
|
'etag',
|
||||||
|
'last-modified',
|
||||||
|
'object',
|
||||||
|
'x-object-manifest',
|
||||||
|
)
|
||||||
|
self.assertEqual(collist, columns)
|
||||||
|
datalist = (
|
||||||
|
object_fakes.ACCOUNT_ID,
|
||||||
|
object_fakes.container_name,
|
||||||
|
'20',
|
||||||
|
'text/plain',
|
||||||
|
'4c4e39a763d58392724bccf76a58783a',
|
||||||
|
'yesterday',
|
||||||
|
object_fakes.object_name_1,
|
||||||
|
'manifest',
|
||||||
|
)
|
||||||
|
self.assertEqual(datalist, data)
|
Loading…
Reference in New Issue
Block a user