예제 #1
0
 def handle(self, request, data):
     cont_name = data['name']
     cont_name = cont_name.encode('utf-8')
     cont_name = cont_name.replace('/', '%2F')
     try:
         api.swift_create_container(request, cont_name)
         messages.success(request, "Container was successfully created.")
     except InvalidContainerName as e:
         messages.error(request, "Invalid Container Name %s" % str(e))
     except Exception, e:
         messages.error(request, 'Unable to create container. \
                    Perhaps you do not have right permission : %s'  % str(e))
예제 #2
0
 def handle(self, request, data):
     cont_name = data['name']
     cont_name = cont_name.encode('utf-8')
     cont_name = cont_name.replace('/', '%2F')
     try:
         api.swift_create_container(request, cont_name)
         messages.success(request, "Container was successfully created.")
     except InvalidContainerName as e:
         messages.error(request, "Invalid Container Name %s" % str(e))
     except Exception, e:
         messages.error(
             request, 'Unable to create container. \
                    Perhaps you do not have right permission : %s' % str(e))
    def test_create_container_post(self):
        formData = {'name': 'containerName', 'method': 'CreateContainer'}

        self.mox.StubOutWithMock(api, 'swift_create_container')
        api.swift_create_container(IsA(http.HttpRequest), 'CreateContainer')

        self.mox.StubOutWithMock(messages, 'success')
        messages.success(IgnoreArg(), IsA(str))

        res = self.client.post(
            reverse('dash_containers_create', args=[self.request.user.tenant]),
            formData)

        self.assertRedirectsNoFollow(
            res, reverse('dash_containers', args=[self.request.user.tenant]))
    def test_create_container_post(self):
        formData = {'name': 'containerName',
                    'method': 'CreateContainer'}

        self.mox.StubOutWithMock(api, 'swift_create_container')
        api.swift_create_container(
                IsA(http.HttpRequest), 'CreateContainer')

        self.mox.StubOutWithMock(messages, 'success')
        messages.success(IgnoreArg(), IsA(str))

        res = self.client.post(reverse('dash_containers_create',
                                       args=[self.request.user.tenant]),
                               formData)

        self.assertRedirectsNoFollow(res, reverse('dash_containers',
                                          args=[self.request.user.tenant]))
예제 #5
0
    def test_swift_create_container(self):
        NAME = "containerName"

        swift_api = self.stub_swift_api()
        self.mox.StubOutWithMock(api, "swift_container_exists")

        api.swift_container_exists(self.request, NAME).AndReturn(False)
        swift_api.create_container(NAME).AndReturn(TEST_RETURN)

        self.mox.ReplayAll()

        ret_val = api.swift_create_container(self.request, NAME)

        self.assertIsInstance(ret_val, api.Container)
        self.assertEqual(ret_val._apiresource, TEST_RETURN)

        self.mox.VerifyAll()
예제 #6
0
 def handle(self, request, data):
     api.swift_create_container(request, data['name'])
     messages.success(request, "Container was successfully created.")
     return shortcuts.redirect("dash_containers", request.user.tenant_id)
 def handle(self, request, data):
     api.swift_create_container(request, data['name'])
     messages.success(request, "Container was successfully created.")
     return shortcuts.redirect("dash_containers", request.user.tenant)