示例#1
0
    def handle(self, request, data):
        orig_container_name = data['orig_container_name']
        orig_object_name = data['orig_object_name']
        new_container_name = data['new_container_name']
        new_object_name = data['new_object_name']

        api.chase_copy_object(request, orig_container_name,
                              orig_object_name, new_container_name,
                              new_object_name)

        messages.success(request,
                _('Object was successfully copied to %(container)s\%(obj)s') %
                {"container": new_container_name, "obj": new_object_name})

        return shortcuts.redirect("steer:engine:containers:object_index",
                                  data['new_container_name'])
示例#2
0
    def handle(self, request, data):
        orig_container_name = data['orig_container_name']
        orig_object_name = data['orig_object_name']
        new_container_name = data['new_container_name']
        new_object_name = data['new_object_name']

        api.chase_copy_object(request, orig_container_name, orig_object_name,
                              new_container_name, new_object_name)

        messages.success(
            request,
            _('Object was successfully copied to %(container)s\%(obj)s') % {
                "container": new_container_name,
                "obj": new_object_name
            })

        return shortcuts.redirect("steer:engine:containers:object_index",
                                  data['new_container_name'])
示例#3
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, 'chase_get_containers')
        api.chase_get_containers(IsA(http.HttpRequest)).AndReturn(
            ([container], False))

        self.mox.StubOutWithMock(api, 'chase_copy_object')
        api.chase_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('steer:engine:containers:object_copy',
                    args=[ORIG_CONTAINER_NAME, ORIG_OBJECT_NAME]), formData)

        self.assertRedirectsNoFollow(
            res,
            reverse('steer:engine:containers:object_index',
                    args=[NEW_CONTAINER_NAME]))
示例#4
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, 'chase_get_containers')
        api.chase_get_containers(
                IsA(http.HttpRequest)).AndReturn(([container], False))

        self.mox.StubOutWithMock(api, 'chase_copy_object')
        api.chase_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('steer:engine:containers:object_copy',
                                       args=[ORIG_CONTAINER_NAME,
                                             ORIG_OBJECT_NAME]),
                              formData)

        self.assertRedirectsNoFollow(res,
                            reverse('steer:engine:containers:object_index',
                                    args=[NEW_CONTAINER_NAME]))