예제 #1
0
def test_delete_all():
    coll1_name = uuid.uuid4().hex
    coll1 = Collection.create("/", coll1_name)
    coll2 = Collection.create(coll1.path, uuid.uuid4().hex)
    coll5 = Collection.create(coll2.path, uuid.uuid4().hex)
    resc1 = Resource.create(coll1.path,
                            uuid.uuid4().hex,
                            url="http://www.google.fr")
    Collection.delete_all("/{}/".format(coll1_name))

    assert Collection.find(coll1_name) == None

    assert Collection.delete_all("/unknown/") == None
예제 #2
0
 def delete_container(self, path):
     """Delete a container"""
     collection = Collection.find(path)
     if not collection:
         self.logger.info(u"Fail to delete collection at '{}'".format(path))
         return Response(status=HTTP_404_NOT_FOUND)
     if not collection.user_can(self.user, "delete"):
         self.logger.warning(
             u"User {} tried to delete container '{}'".format(
                 self.user, path))
         return Response(status=HTTP_403_FORBIDDEN)
     Collection.delete_all(collection.path)
     self.logger.info(
         u"The container '{}' was successfully deleted".format(path))
     return Response(status=HTTP_204_NO_CONTENT)