コード例 #1
0
ファイル: tests.py プロジェクト: mshabdiz/horizon
    def test_copy(self):
        container_1 = self.containers.get(name=u"container_one\u6346")
        container_2 = self.containers.get(name=u"container_two\u6346")
        obj = self.objects.first()

        self.mox.StubOutWithMock(api, 'swift_get_containers')
        self.mox.StubOutWithMock(api, 'swift_copy_object')
        ret = (self.containers.list(), False)
        api.swift_get_containers(IsA(http.HttpRequest)).AndReturn(ret)
        api.swift_copy_object(IsA(http.HttpRequest), container_1.name,
                              obj.name, container_2.name, obj.name)
        self.mox.ReplayAll()

        formData = {
            'method': forms.CopyObject.__name__,
            'new_container_name': container_2.name,
            'new_object_name': obj.name,
            'orig_container_name': container_1.name,
            'orig_object_name': obj.name
        }
        copy_url = reverse('horizon:nova:containers:object_copy',
                           args=[container_1.name, obj.name])
        res = self.client.post(copy_url, formData)
        index_url = reverse('horizon:nova:containers:object_index',
                            args=[container_2.name])
        self.assertRedirectsNoFollow(res, index_url)
コード例 #2
0
ファイル: tests.py プロジェクト: AsylumCorp/horizon
    def test_copy(self):
        container_1 = self.containers.get(name=u"container_one\u6346")
        container_2 = self.containers.get(name=u"container_two\u6346")
        obj = self.objects.first()

        self.mox.StubOutWithMock(api, 'swift_get_containers')
        self.mox.StubOutWithMock(api, 'swift_copy_object')
        ret = (self.containers.list(), False)
        api.swift_get_containers(IsA(http.HttpRequest)).AndReturn(ret)
        api.swift_copy_object(IsA(http.HttpRequest),
                              container_1.name,
                              obj.name,
                              container_2.name,
                              obj.name)
        self.mox.ReplayAll()

        formData = {'method': forms.CopyObject.__name__,
                    'new_container_name': container_2.name,
                    'new_object_name': obj.name,
                    'orig_container_name': container_1.name,
                    'orig_object_name': obj.name}
        copy_url = reverse('horizon:nova:containers:object_copy',
                           args=[container_1.name, obj.name])
        res = self.client.post(copy_url, formData)
        index_url = reverse('horizon:nova:containers:object_index',
                            args=[container_2.name])
        self.assertRedirectsNoFollow(res, index_url)
コード例 #3
0
ファイル: tests.py プロジェクト: AsylumCorp/horizon
    def test_copy_index(self):
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        ret = (self.containers.list(), False)
        api.swift_get_containers(IsA(http.HttpRequest)).AndReturn(ret)
        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:containers:object_copy',
                                      args=[self.containers.first().name,
                                            self.objects.first().name]))
        self.assertTemplateUsed(res, 'nova/objects/copy.html')
コード例 #4
0
ファイル: tests.py プロジェクト: nimbis/horizon
    def test_index(self):
        containers = self.containers.list()
        self.mox.StubOutWithMock(api, "swift_get_containers")
        api.swift_get_containers(IsA(http.HttpRequest), marker=None).AndReturn((containers, False))
        self.mox.ReplayAll()

        res = self.client.get(CONTAINER_INDEX_URL)

        self.assertTemplateUsed(res, "nova/containers/index.html")
        self.assertIn("table", res.context)
        resp_containers = res.context["table"].data
        self.assertEqual(len(resp_containers), len(containers))
コード例 #5
0
ファイル: tests.py プロジェクト: mshabdiz/horizon
    def test_copy_index(self):
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        ret = (self.containers.list(), False)
        api.swift_get_containers(IsA(http.HttpRequest)).AndReturn(ret)
        self.mox.ReplayAll()

        res = self.client.get(
            reverse(
                'horizon:nova:containers:object_copy',
                args=[self.containers.first().name,
                      self.objects.first().name]))
        self.assertTemplateUsed(res, 'nova/containers/copy.html')
コード例 #6
0
ファイル: tests.py プロジェクト: mshabdiz/horizon
    def test_index(self):
        containers = self.containers.list()
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(IsA(http.HttpRequest), marker=None) \
                                .AndReturn((containers, False))
        self.mox.ReplayAll()

        res = self.client.get(CONTAINER_INDEX_URL)

        self.assertTemplateUsed(res, 'nova/containers/index.html')
        self.assertIn('table', res.context)
        resp_containers = res.context['table'].data
        self.assertEqual(len(resp_containers), len(containers))
コード例 #7
0
ファイル: tests.py プロジェクト: JetStreamPilot/horizon
    def test_index_no_container_selected(self):
        containers = self.containers.list()
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(IsA(http.HttpRequest), marker=None) \
                                .AndReturn((containers, False))
        self.mox.ReplayAll()

        res = self.client.get(CONTAINER_INDEX_URL)

        self.assertTemplateUsed(res, 'nova/containers/index.html')
        self.assertIn('table', res.context)
        resp_containers = res.context['table'].data
        self.assertEqual(len(resp_containers), len(containers))
コード例 #8
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_index(self):
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(
                IsA(http.HttpRequest), marker=None).AndReturn([self.container])

        self.mox.ReplayAll()

        res = self.client.get(CONTAINER_INDEX_URL)

        self.assertTemplateUsed(res, 'nova/containers/index.html')
        self.assertIn('containers', res.context)
        containers = res.context['containers']

        self.assertEqual(len(containers), 1)
        self.assertEqual(containers[0].name, 'containerName')
コード例 #9
0
ファイル: tests.py プロジェクト: ohnoimdead/horizon-1
    def test_index(self):
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(
                IsA(http.HttpRequest), marker=None).AndReturn(
                        ([self.container], False))

        self.mox.ReplayAll()

        res = self.client.get(CONTAINER_INDEX_URL)

        self.assertTemplateUsed(res, 'nova/containers/index.html')
        self.assertIn('containers', res.context)
        containers = res.context['containers']

        self.assertEqual(len(containers), 1)
        self.assertEqual(containers[0].name, 'containerName')
コード例 #10
0
    def test_copy_index(self):
        OBJECT_NAME = 'objectName'

        container = self.mox.CreateMock(api.Container)
        container.name = self.CONTAINER_NAME

        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(IsA(http.HttpRequest)).AndReturn(
            ([container], False))

        self.mox.ReplayAll()

        res = self.client.get(
            reverse('horizon:nova:containers:object_copy',
                    args=[self.CONTAINER_NAME, OBJECT_NAME]))

        self.assertTemplateUsed(res, 'nova/objects/copy.html')
コード例 #11
0
ファイル: tests.py プロジェクト: emmasteimann/horizon
    def test_copy_index(self):
        OBJECT_NAME = 'objectName'

        container = self.mox.CreateMock(api.Container)
        container.name = self.CONTAINER_NAME

        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(
                IsA(http.HttpRequest)).AndReturn(([container], False))

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:containers:object_copy',
                                      args=[self.CONTAINER_NAME,
                                            OBJECT_NAME]))

        self.assertTemplateUsed(res, 'nova/objects/copy.html')
コード例 #12
0
ファイル: views.py プロジェクト: nimbis/horizon
 def get_form_kwargs(self):
     kwargs = super(CopyView, self).get_form_kwargs()
     try:
         containers = api.swift_get_containers(self.request)
     except:
         redirect = reverse("horizon:nova:containers:index")
         exceptions.handle(self.request, _("Unable to list containers."), redirect=redirect)
     kwargs["containers"] = [(c.name, c.name) for c in containers[0]]
     return kwargs
コード例 #13
0
ファイル: views.py プロジェクト: nimbis/horizon
 def get_data(self):
     containers = []
     self._more = None
     marker = self.request.GET.get("marker", None)
     try:
         containers, self._more = api.swift_get_containers(self.request, marker=marker)
     except:
         msg = _("Unable to retrieve container list.")
         exceptions.handle(self.request, msg)
     return containers
コード例 #14
0
    def test_swift_get_containers(self):
        containers = self.containers.list()
        swift_api = self.stub_swiftclient()
        swift_api.get_all_containers(limit=1001,
                                     marker=None).AndReturn(containers)
        self.mox.ReplayAll()

        (conts, more) = api.swift_get_containers(self.request)
        self.assertEqual(len(conts), len(containers))
        self.assertFalse(more)
コード例 #15
0
ファイル: swift_tests.py プロジェクト: jakedahn/horizon
    def test_swift_get_containers(self):
        containers = self.containers.list()
        swift_api = self.stub_swiftclient()
        swift_api.get_all_containers(limit=1001,
                                     marker=None).AndReturn(containers)
        self.mox.ReplayAll()

        (conts, more) = api.swift_get_containers(self.request)
        self.assertEqual(len(conts), len(containers))
        self.assertFalse(more)
コード例 #16
0
ファイル: views.py プロジェクト: zhang-hua/horizon
 def get_containers_data(self):
     containers = []
     self._more = None
     marker = self.request.GET.get('marker', None)
     try:
         containers, self._more = api.swift_get_containers(self.request,
                                                           marker=marker)
     except:
         msg = _('Unable to retrieve container list.')
         exceptions.handle(self.request, msg)
     return containers
コード例 #17
0
ファイル: views.py プロジェクト: zhang-hua/horizon
 def get_form_kwargs(self):
     kwargs = super(CopyView, self).get_form_kwargs()
     try:
         containers = api.swift_get_containers(self.request)
     except:
         redirect = reverse("horizon:nova:containers:index")
         exceptions.handle(self.request,
                           _('Unable to list containers.'),
                           redirect=redirect)
     kwargs['containers'] = [(c.name, c.name) for c in containers[0]]
     return kwargs
コード例 #18
0
    def test_index_container_selected(self):
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        self.mox.StubOutWithMock(api, 'swift_get_objects')
        containers = (self.containers.list(), False)
        ret = (self.objects.list(), False)
        api.swift_get_containers(IsA(http.HttpRequest),
                                 marker=None).AndReturn(containers)
        api.swift_get_objects(IsA(http.HttpRequest),
                              self.containers.first().name,
                              marker=None,
                              prefix=None).AndReturn(ret)
        self.mox.ReplayAll()

        res = self.client.get(
            reverse('horizon:project:containers:index',
                    args=[wrap_delimiter(self.containers.first().name)]))
        self.assertTemplateUsed(res, 'project/containers/index.html')
        # UTF8 encoding here to ensure there aren't problems with Nose output.
        expected = [obj.name.encode('utf8') for obj in self.objects.list()]
        self.assertQuerysetEqual(res.context['objects_table'].data, expected,
                                 lambda obj: obj.name.encode('utf8'))
コード例 #19
0
ファイル: swift_tests.py プロジェクト: 1ukash/horizon
    def test_swift_get_containers(self):
        containers = self.containers.list()
        cont_data = [c._apidict for c in containers]
        swift_api = self.stub_swiftclient()
        swift_api.get_account(limit=1001,
                              marker=None,
                              full_listing=True).AndReturn([{}, cont_data])
        self.mox.ReplayAll()

        (conts, more) = api.swift_get_containers(self.request)
        self.assertEqual(len(conts), len(containers))
        self.assertFalse(more)
コード例 #20
0
ファイル: views.py プロジェクト: BillTheBest/horizon
def index(request):
    marker = request.GET.get('marker', None)

    delete_form, handled = DeleteContainer.maybe_handle(request)
    if handled:
        return handled

    containers = api.swift_get_containers(request, marker=marker)

    return shortcuts.render(request,
                            'nova/containers/index.html',
                            {'containers': containers,
                             'delete_form': delete_form})
コード例 #21
0
ファイル: tests.py プロジェクト: katzj/horizon
    def test_copy(self):
        NEW_CONTAINER_NAME = self.CONTAINER_NAME
        NEW_OBJECT_NAME = 'newObjectName'
        ORIG_CONTAINER_NAME = 'origContainerName'
        ORIG_OBJECT_NAME = 'origObjectName'

        formData = {'method': 'CopyObject',
                    'new_container_name': NEW_CONTAINER_NAME,
                    'new_object_name': NEW_OBJECT_NAME,
                    'orig_container_name': ORIG_CONTAINER_NAME,
                    'orig_object_name': ORIG_OBJECT_NAME}

        container = self.mox.CreateMock(api.Container)
        container.name = self.CONTAINER_NAME

        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(
                IsA(http.HttpRequest)).AndReturn([container])

        self.mox.StubOutWithMock(api, 'swift_copy_object')
        api.swift_copy_object(IsA(http.HttpRequest),
                              ORIG_CONTAINER_NAME,
                              ORIG_OBJECT_NAME,
                              NEW_CONTAINER_NAME,
                              NEW_OBJECT_NAME)

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:containers:object_copy',
                                       args=[ORIG_CONTAINER_NAME,
                                             ORIG_OBJECT_NAME]),
                              formData)

        self.assertRedirectsNoFollow(res,
                            reverse('horizon:nova:containers:object_copy',
                                    args=[ORIG_CONTAINER_NAME,
                                          ORIG_OBJECT_NAME]))

        self.mox.VerifyAll()
コード例 #22
0
ファイル: views.py プロジェクト: ehazlett/horizon
def index(request):
    marker = request.GET.get('marker', None)

    delete_form, handled = DeleteContainer.maybe_handle(request)
    if handled:
        return handled

    try:
        containers, more = api.swift_get_containers(request, marker=marker)
    except Exception, e:
        containers, more = None, None
        msg = _('Error retrieving container list: %s') % e
        LOG.exception(msg)
        messages.error(request, msg)
コード例 #23
0
def index(request):
    marker = request.GET.get('marker', None)

    delete_form, handled = DeleteContainer.maybe_handle(request)
    if handled:
        return handled

    try:
        containers, more = api.swift_get_containers(request, marker=marker)
    except Exception, e:
        containers, more = None, None
        msg = _('Error retrieving container list: %s') % e
        LOG.exception(msg)
        messages.error(request, msg)
コード例 #24
0
ファイル: views.py プロジェクト: termie/horizon
def index(request):
    marker = request.GET.get('marker', None)

    delete_form, handled = DeleteContainer.maybe_handle(request)
    if handled:
        return handled

    containers, more = api.swift_get_containers(request, marker=marker)

    return shortcuts.render(request, 'nova/containers/index.html', {
        'containers': containers,
        'delete_form': delete_form,
        'more': more
    })
コード例 #25
0
ファイル: tests.py プロジェクト: JetStreamPilot/horizon
    def test_index_container_selected(self):
        self.mox.StubOutWithMock(api, 'swift_get_containers')
        self.mox.StubOutWithMock(api, 'swift_get_objects')
        containers = (self.containers.list(), False)
        ret = (self.objects.list(), False)
        api.swift_get_containers(IsA(http.HttpRequest),
                                 marker=None).AndReturn(containers)
        api.swift_get_objects(IsA(http.HttpRequest),
                              self.containers.first().name,
                              marker=None,
                              prefix=None).AndReturn(ret)
        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:containers:index',
                                      args=[wrap_delimiter(self.containers
                                                               .first()
                                                               .name)]))
        self.assertTemplateUsed(res, 'nova/containers/index.html')
        # UTF8 encoding here to ensure there aren't problems with Nose output.
        expected = [obj.name.encode('utf8') for obj in self.objects.list()]
        self.assertQuerysetEqual(res.context['objects_table'].data,
                                 expected,
                                 lambda obj: obj.name.encode('utf8'))
コード例 #26
0
    def test_copy(self):
        NEW_CONTAINER_NAME = self.CONTAINER_NAME
        NEW_OBJECT_NAME = 'newObjectName'
        ORIG_CONTAINER_NAME = 'origContainerName'
        ORIG_OBJECT_NAME = 'origObjectName'

        formData = {
            'method': 'CopyObject',
            'new_container_name': NEW_CONTAINER_NAME,
            'new_object_name': NEW_OBJECT_NAME,
            'orig_container_name': ORIG_CONTAINER_NAME,
            'orig_object_name': ORIG_OBJECT_NAME
        }

        container = self.mox.CreateMock(api.Container)
        container.name = self.CONTAINER_NAME

        self.mox.StubOutWithMock(api, 'swift_get_containers')
        api.swift_get_containers(IsA(http.HttpRequest)).AndReturn(
            ([container], False))

        self.mox.StubOutWithMock(api, 'swift_copy_object')
        api.swift_copy_object(IsA(http.HttpRequest), ORIG_CONTAINER_NAME,
                              ORIG_OBJECT_NAME, NEW_CONTAINER_NAME,
                              NEW_OBJECT_NAME)

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:nova:containers:object_copy',
                    args=[ORIG_CONTAINER_NAME, ORIG_OBJECT_NAME]), formData)

        self.assertRedirectsNoFollow(
            res,
            reverse('horizon:nova:containers:object_index',
                    args=[NEW_CONTAINER_NAME]))
コード例 #27
0
ファイル: views.py プロジェクト: termie/horizon
def object_copy(request, container_name, object_name):
    containers = \
            [(c.name, c.name) for c in api.swift_get_containers(
                    request)[0]]
    form, handled = CopyObject.maybe_handle(request, containers=containers)

    if handled:
        return handled

    form.fields['new_container_name'].initial = container_name
    form.fields['orig_container_name'].initial = container_name
    form.fields['orig_object_name'].initial = object_name

    return shortcuts.render(
        request, 'nova/objects/copy.html', {
            'container_name': container_name,
            'object_name': object_name,
            'copy_form': form
        })
コード例 #28
0
ファイル: views.py プロジェクト: BillTheBest/horizon
def object_copy(request, container_name, object_name):
    containers = \
            [(c.name, c.name) for c in api.swift_get_containers(
                    request)]
    form, handled = CopyObject.maybe_handle(request,
            containers=containers)

    if handled:
        return handled

    form.fields['new_container_name'].initial = container_name
    form.fields['orig_container_name'].initial = container_name
    form.fields['orig_object_name'].initial = object_name

    return shortcuts.render(request,
                            'nova/objects/copy.html',
                            {'container_name': container_name,
                             'object_name': object_name,
                             'copy_form': form})