~ubuntu-branches/ubuntu/precise/horizon/precise-updates

« back to all changes in this revision

Viewing changes to horizon/tests/test_data/swift_data.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-03-02 12:11:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20120302121159-65b88lcl4slve26i
Tags: 2012.1~e4-0ubuntu1
* New upstream version.
* debian/rules: Update due to upstream build changes.
* debian/control: Update standards-version.
* debian/patches/openstack-config-settings.patch: Dropped
* debian/patches/fix-dashboard-django-wsgi.patch: Refreshed
* debian/patches/fix-dashboard-manage.patch: Refreshed
* debian/openstack-dashboard.install: Update due to upstream build changes.
* debian/dashboard: Update to upstream build changes.
* debian/pydist-overrides: Dont try to install python-django-nose-selenium.
* debian/openstack-dashboard.install: Add missing config files.
* debian/rules: Fix broken settings.py
* debian/patches/pkg-setup.patch: Copy missing templates, shameously
  taken from debian
* debian/patches/fix-broken-tarbll.patch: Add missing files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2012 Nebula, Inc.
 
2
#
 
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
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
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
 
13
#    under the License.
 
14
 
 
15
import new
 
16
 
 
17
from django import http
 
18
 
 
19
from cloudfiles import container, storage_object
 
20
 
 
21
from horizon.api import base
 
22
from .utils import TestDataContainer
 
23
 
 
24
 
 
25
def data(TEST):
 
26
    TEST.containers = TestDataContainer()
 
27
    TEST.objects = TestDataContainer()
 
28
 
 
29
    request = http.HttpRequest()
 
30
    request.user = TEST.user
 
31
 
 
32
    class FakeConnection(object):
 
33
        def __init__(self):
 
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"
 
38
 
 
39
    conn = FakeConnection()
 
40
 
 
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)
 
44
 
 
45
    object_dict = {"name": u"test_object\u6346",
 
46
                   "content_type": u"text/plain",
 
47
                   "bytes": 128,
 
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)
 
55
 
 
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,
 
59
                                            objects=obj_dicts)
 
60
 
 
61
    list_method = new.instancemethod(get_object_result_list, TEST.objects)
 
62
    TEST.objects.list = list_method