Example #1
0
    def test_delete_container_nonempty(self):
        container = self.containers.first()
        self.mox.StubOutWithMock(api, 'swift_delete_container')
        exc = ContainerNotEmpty('containerNotEmpty')
        exc.silence_logging = True
        api.swift_delete_container(IsA(http.HttpRequest),
                                   container.name).AndRaise(exc)
        self.mox.ReplayAll()

        action_string = u"containers__delete__%s" % container.name
        form_data = {"action": action_string}
        req = self.factory.post(CONTAINER_INDEX_URL, form_data)
        table = ContainersTable(req, self.containers.list())
        handled = table.maybe_handle()
        self.assertEqual(handled['location'], CONTAINER_INDEX_URL)
Example #2
0
    def test_delete_container_nonempty(self):
        container = self.containers.first()
        self.mox.StubOutWithMock(api, 'swift_delete_container')
        exc = ContainerNotEmpty('containerNotEmpty')
        exc.silence_logging = True
        api.swift_delete_container(IsA(http.HttpRequest),
                                   container.name).AndRaise(exc)
        self.mox.ReplayAll()

        action_string = u"containers__delete__%s" % container.name
        form_data = {"action": action_string}
        req = self.factory.post(CONTAINER_INDEX_URL, form_data)
        table = ContainersTable(req, self.containers.list())
        handled = table.maybe_handle()
        self.assertEqual(handled['location'], CONTAINER_INDEX_URL)
    def test_delete_container_nonempty(self):
        formData = {
            'container_name': 'containerName',
            'method': 'DeleteContainer'
        }

        exception = ContainerNotEmpty('containerNotEmpty')

        self.mox.StubOutWithMock(api, 'swift_delete_container')
        api.swift_delete_container(IsA(http.HttpRequest),
                                   'containerName').AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')

        messages.error(IgnoreArg(), IsA(unicode))

        self.mox.ReplayAll()

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

        self.assertRedirectsNoFollow(
            res, reverse('dash_containers', args=['tenant']))

        self.mox.VerifyAll()
Example #4
0
    def test_delete_container_nonempty(self):
        self.mox.StubOutWithMock(api, 'swift_delete_container')

        exception = ContainerNotEmpty('containerNotEmpty')
        api.swift_delete_container(IsA(http.HttpRequest),
                                   'containerName').AndRaise(exception)

        self.mox.ReplayAll()

        action_string = "containers__delete__%s" % self.container.name
        form_data = {"action": action_string}
        req = self.factory.post(CONTAINER_INDEX_URL, form_data)
        table = ContainersTable(req, self.containers)
        handled = table.maybe_handle()

        self.assertEqual(handled['location'], CONTAINER_INDEX_URL)
Example #5
0
    def test_delete_container_nonempty(self):
        formData = {
            'container_name': 'containerName',
            'method': 'DeleteContainer'
        }

        exception = ContainerNotEmpty('containerNotEmpty')

        self.mox.StubOutWithMock(api, 'chase_delete_container')
        api.chase_delete_container(IsA(http.HttpRequest),
                                   'containerName').AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')

        messages.error(IgnoreArg(), IsA(unicode))

        self.mox.ReplayAll()

        res = self.client.post(CONTAINER_INDEX_URL, formData)

        self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)