Example #1
0
 def handle(self, request, data):
     try:
         api.swift_create_container(request, data['name'])
         messages.success(request, _("Container created successfully."))
     except:
         exceptions.handle(request, _('Unable to create container.'))
     return shortcuts.redirect("horizon:nova:containers:index")
Example #2
0
    def handle(self, request, data):
        try:
            if not data['parent']:
                # Create a container
                api.swift_create_container(request, data["name"])
                messages.success(request, _("Container created successfully."))
            else:
                # Create a pseudo-folder
                container, slash, remainder = data['parent'].partition("/")
                remainder = remainder.rstrip("/")
                subfolder_name = "/".join([bit for bit
                                           in (remainder, data['name'])
                                           if bit])
                api.swift_create_subfolder(request,
                                           container,
                                           subfolder_name)
                messages.success(request, _("Folder created successfully."))
                url = "horizon:nova:containers:object_index"
                if remainder:
                    remainder = remainder.rstrip("/")
                    remainder += "/"
                return shortcuts.redirect(url, container, remainder)

        except:
            exceptions.handle(request, _('Unable to create container.'))

        return shortcuts.redirect("horizon:nova:containers:index")
Example #3
0
 def handle(self, request, data):
     try:
         api.swift_create_container(request, data['name'])
         messages.success(request, _("Container created successfully."))
     except:
         exceptions.handle(request, _('Unable to create container.'))
     return shortcuts.redirect("horizon:nova:containers:index")
Example #4
0
 def test_swift_create_duplicate_container(self):
     container = self.containers.first()
     swift_api = self.stub_swiftclient()
     swift_api.get_container(container.name).AndReturn(container)
     self.mox.ReplayAll()
     # Verification handled by mox, no assertions needed.
     with self.assertRaises(exceptions.AlreadyExists):
         api.swift_create_container(self.request, container.name)
Example #5
0
 def test_swift_create_duplicate_container(self):
     container = self.containers.first()
     swift_api = self.stub_swiftclient()
     swift_api.get_container(container.name).AndReturn(container)
     self.mox.ReplayAll()
     # Verification handled by mox, no assertions needed.
     with self.assertRaises(exceptions.AlreadyExists):
         api.swift_create_container(self.request, container.name)
Example #6
0
    def test_create_container_post(self):
        self.mox.StubOutWithMock(api, "swift_create_container")
        api.swift_create_container(IsA(http.HttpRequest), self.containers.first().name)
        self.mox.ReplayAll()

        formData = {"name": self.containers.first().name, "method": forms.CreateContainer.__name__}
        res = self.client.post(reverse("horizon:nova:containers:create"), formData)
        self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)
Example #7
0
 def test_swift_create_duplicate_container(self):
     container = self.containers.first()
     swift_api = self.stub_swiftclient(expected_calls=2)
     # Check for existence, then create
     exc = self.exceptions.swift
     swift_api.head_container(container.name).AndRaise(exc)
     swift_api.put_container(container.name).AndReturn(container)
     self.mox.ReplayAll()
     # Verification handled by mox, no assertions needed.
     api.swift_create_container(self.request, container.name)
Example #8
0
 def test_swift_create_container(self):
     container = self.containers.first()
     swift_api = self.stub_swiftclient(expected_calls=2)
     # Check for existence, then create
     exc = cloudfiles.errors.NoSuchContainer()
     swift_api.get_container(container.name).AndRaise(exc)
     swift_api.create_container(container.name).AndReturn(container)
     self.mox.ReplayAll()
     # Verification handled by mox, no assertions needed.
     api.swift_create_container(self.request, container.name)
Example #9
0
 def test_swift_create_container(self):
     container = self.containers.first()
     swift_api = self.stub_swiftclient(expected_calls=2)
     # Check for existence, then create
     exc = cloudfiles.errors.NoSuchContainer()
     swift_api.get_container(container.name).AndRaise(exc)
     swift_api.create_container(container.name).AndReturn(container)
     self.mox.ReplayAll()
     # Verification handled by mox, no assertions needed.
     api.swift_create_container(self.request, container.name)
Example #10
0
    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), u'containerName')

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:containers:create'),
                               formData)

        self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)
Example #11
0
    def test_create_container_post(self):
        self.mox.StubOutWithMock(api, 'swift_create_container')
        api.swift_create_container(IsA(http.HttpRequest),
                                   self.containers.first().name)
        self.mox.ReplayAll()

        formData = {
            'name': self.containers.first().name,
            'method': forms.CreateContainer.__name__
        }
        res = self.client.post(reverse('horizon:nova:containers:create'),
                               formData)
        self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)
Example #12
0
    def test_create_container_post(self):
        self.mox.StubOutWithMock(api, 'swift_create_container')
        api.swift_create_container(IsA(http.HttpRequest),
                                   self.containers.first().name)
        self.mox.ReplayAll()

        formData = {'name': self.containers.first().name,
                    'method': forms.CreateContainer.__name__}
        res = self.client.post(reverse('horizon:nova:containers:create'),
                               formData)
        url = reverse('horizon:nova:containers:index',
                      args=[wrap_delimiter(self.containers.first().name)])
        self.assertRedirectsNoFollow(res, url)
Example #13
0
    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), u'containerName')

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:containers:create'),
                               formData)

        self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)
Example #14
0
    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(basestring))

        res = self.client.post(reverse('horizon:nova:containers:create'),
                               formData)

        self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)
Example #15
0
    def test_create_container_post(self):
        self.mox.StubOutWithMock(api, 'swift_create_container')
        api.swift_create_container(IsA(http.HttpRequest),
                                   self.containers.first().name)
        self.mox.ReplayAll()

        formData = {
            'name': self.containers.first().name,
            'method': forms.CreateContainer.__name__
        }
        res = self.client.post(reverse('horizon:project:containers:create'),
                               formData)
        url = reverse('horizon:project:containers:index',
                      args=[wrap_delimiter(self.containers.first().name)])
        self.assertRedirectsNoFollow(res, url)
Example #16
0
 def handle(self, request, data):
     try:
         if not data['parent']:
             # Create a container
             api.swift_create_container(request, data["name"])
             messages.success(request, _("Container created successfully."))
         else:
             # Create a pseudo-folder
             container, slash, remainder = data['parent'].partition("/")
             remainder = remainder.rstrip("/")
             subfolder_name = "/".join(
                 [bit for bit in (remainder, data['name']) if bit])
             api.swift_create_subfolder(request, container, subfolder_name)
             messages.success(request, _("Folder created successfully."))
         return True
     except:
         exceptions.handle(request, _('Unable to create container.'))
Example #17
0
 def handle(self, request, data):
     try:
         if not data['parent']:
             # Create a container
             api.swift_create_container(request, data["name"])
             messages.success(request, _("Container created successfully."))
         else:
             # Create a pseudo-folder
             container, slash, remainder = data['parent'].partition("/")
             remainder = remainder.rstrip("/")
             subfolder_name = "/".join([bit for bit
                                        in (remainder, data['name'])
                                        if bit])
             api.swift_create_subfolder(request,
                                        container,
                                        subfolder_name)
             messages.success(request, _("Folder created successfully."))
         return True
     except:
         exceptions.handle(request, _('Unable to create container.'))
Example #18
0
    def handle(self, request, data):
        try:
            if not data['parent']:
                # Create a container
                api.swift_create_container(request, data["name"])
                messages.success(request, _("Container created successfully."))
            else:
                # Create a pseudo-folder
                container, slash, remainder = data['parent'].partition("/")
                remainder = remainder.rstrip("/")
                subfolder_name = "/".join(
                    [bit for bit in (remainder, data['name']) if bit])
                api.swift_create_subfolder(request, container, subfolder_name)
                messages.success(request, _("Folder created successfully."))
                url = "horizon:nova:containers:object_index"
                if remainder:
                    remainder = remainder.rstrip("/")
                    remainder += "/"
                return shortcuts.redirect(url, container, remainder)

        except:
            exceptions.handle(request, _('Unable to create container.'))

        return shortcuts.redirect("horizon:nova:containers:index")
Example #19
0
 def handle(self, request, data):
     api.swift_create_container(request, data['name'])
     messages.success(request, _("Container was successfully created."))
     return shortcuts.redirect("horizon:nova:containers:index")
Example #20
0
 def handle(self, request, data):
     api.swift_create_container(request, data['name'])
     messages.success(request, _("Container was successfully created."))
     return shortcuts.redirect("horizon:nova:containers:index")