def test_delete_container(self): container = self.containers.get(name=u"container_two\u6346") api.swift.swift_delete_container(IsA(http.HttpRequest), container.name) 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): container = self.containers.first() objects = self.objects.list() api.swift.swift_get_objects(IsA(http.HttpRequest), container.name).AndReturn([objects, False]) 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) self.assertEqual(unicode(list(req._messages)[0].message), u"The container cannot be deleted " u"since it's not empty.")
def test_delete_container_nonempty(self): container = self.containers.first() objects = self.objects.list() api.swift.swift_get_objects(IsA(http.HttpRequest), container.name).AndReturn([objects, False]) 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) self.assertEqual( unicode(list(req._messages)[0].message), u"The container cannot be deleted " u"since it's not empty.")