1
# Copyright 2012 Nebula, Inc.
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
17
from django import http
19
from cloudfiles import container, storage_object
21
from horizon.api import base
22
from .utils import TestDataContainer
26
TEST.containers = TestDataContainer()
27
TEST.objects = TestDataContainer()
29
request = http.HttpRequest()
30
request.user = TEST.user
32
class FakeConnection(object):
34
self.cdn_enabled = False
35
self.uri = base.url_for(request, "object-store")
36
self.token = TEST.token
37
self.user_agent = "python-cloudfiles"
39
conn = FakeConnection()
41
container_1 = container.Container(conn, name=u"container_one\u6346")
42
container_2 = container.Container(conn, name=u"container_two\u6346")
43
TEST.containers.add(container_1, container_2)
45
object_dict = {"name": u"test_object\u6346",
46
"content_type": u"text/plain",
48
"last_modified": None,
49
"hash": u"object_hash"}
50
obj_dicts = [object_dict]
51
for obj_dict in obj_dicts:
52
swift_object = storage_object.Object(container_1,
53
object_record=obj_dict)
54
TEST.objects.add(swift_object)
56
# Override the list method to return the type of list cloudfiles does.
57
def get_object_result_list(self):
58
return storage_object.ObjectResults(container_1,
61
list_method = new.instancemethod(get_object_result_list, TEST.objects)
62
TEST.objects.list = list_method