2012-02-11 18:44:39 -08:00
|
|
|
# Copyright 2012 Nebula, Inc.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2012-10-04 15:43:40 -07:00
|
|
|
from openstack_dashboard.api import swift
|
2013-08-19 09:44:12 -07:00
|
|
|
from openstack_dashboard.openstack.common import timeutils
|
2013-06-10 14:29:44 +02:00
|
|
|
|
2013-08-23 19:24:27 +04:00
|
|
|
from openstack_dashboard.test.test_data import utils
|
2012-02-11 18:44:39 -08:00
|
|
|
|
|
|
|
|
|
|
|
def data(TEST):
|
2013-08-23 19:24:27 +04:00
|
|
|
TEST.containers = utils.TestDataContainer()
|
|
|
|
TEST.objects = utils.TestDataContainer()
|
2012-02-11 18:44:39 -08:00
|
|
|
|
2013-11-08 22:58:07 +01:00
|
|
|
# '%' can break URL if not properly quoted (bug 1231904)
|
|
|
|
container_dict_1 = {"name": u"container_one%\u6346",
|
2013-08-19 09:44:12 -07:00
|
|
|
"container_object_count": 2,
|
|
|
|
"container_bytes_used": 256,
|
|
|
|
"timestamp": timeutils.isotime()}
|
|
|
|
container_1 = swift.Container(container_dict_1)
|
|
|
|
container_dict_2 = {"name": u"container_two\u6346",
|
|
|
|
"container_object_count": 4,
|
|
|
|
"container_bytes_used": 1024,
|
|
|
|
"timestamp": timeutils.isotime()}
|
|
|
|
container_2 = swift.Container(container_dict_2)
|
2012-02-11 18:44:39 -08:00
|
|
|
TEST.containers.add(container_1, container_2)
|
|
|
|
|
2013-11-08 22:58:07 +01:00
|
|
|
object_dict = {"name": u"test_object%\u6346",
|
2012-02-23 17:10:29 -08:00
|
|
|
"content_type": u"text/plain",
|
2012-02-11 18:44:39 -08:00
|
|
|
"bytes": 128,
|
2013-08-19 09:44:12 -07:00
|
|
|
"timestamp": timeutils.isotime(),
|
2012-02-11 18:44:39 -08:00
|
|
|
"last_modified": None,
|
2012-02-23 17:10:29 -08:00
|
|
|
"hash": u"object_hash"}
|
2013-11-08 22:58:07 +01:00
|
|
|
object_dict_2 = {"name": u"test_object_two\u6346",
|
|
|
|
"content_type": u"text/plain",
|
|
|
|
"bytes": 128,
|
|
|
|
"timestamp": timeutils.isotime(),
|
|
|
|
"last_modified": None,
|
|
|
|
"hash": u"object_hash_2"}
|
|
|
|
obj_dicts = [object_dict, object_dict_2]
|
2012-08-12 21:27:21 -07:00
|
|
|
obj_data = "Fake Data"
|
|
|
|
|
2012-02-11 18:44:39 -08:00
|
|
|
for obj_dict in obj_dicts:
|
2012-08-12 21:27:21 -07:00
|
|
|
swift_object = swift.StorageObject(obj_dict,
|
|
|
|
container_1.name,
|
|
|
|
data=obj_data)
|
2012-02-11 18:44:39 -08:00
|
|
|
TEST.objects.add(swift_object)
|