def auth(client):

            def check_file(result):

                @transaction.atomic
                def _check_file():
                    content_blob = services.get_object_or_none(
                        ContentBlob, hash=hash_value)
                    if not content_blob:
                        raise ValueError("content blob is not there")

                d = threads.deferToThread(_check_file)
                return d

            d = client.dummy_authenticate("open sesame")
            filenames = iter('hola_%d' % i for i in xrange(num_files))
            for i in range(num_files):
                d.addCallbacks(lambda _: client.get_root(), client.test_fail)
                d.addCallbacks(
                    lambda root: client.make_file(request.ROOT, root,
                                                  filenames.next()),
                    client.test_fail)
                d.addCallbacks(
                    lambda mkfile_req: client.put_content(
                        request.ROOT,
                        mkfile_req.new_id, NO_CONTENT_HASH, hash_value,
                        crc32_value, size, deflated_size,
                        StringIO(deflated_data)),
                    client.test_fail)
            d.addCallback(check_file)
            d.addCallbacks(client.test_done, client.test_fail)
            return d
Exemplo n.º 2
0
        def auth(client):

            def check_file(result):

                def _check_file():
                    storage_tm.begin()
                    try:
                        store = get_storage_store()
                        content_blob = store.get(model.ContentBlob, hash_value)
                        if not content_blob:
                            raise ValueError("content blob is not there")
                    finally:

                        storage_tm.abort()
                d = threads.deferToThread(_check_file)
                return d

            d = client.dummy_authenticate("open sesame")
            filenames = iter('hola_%d' % i for i in xrange(num_files))
            for i in range(num_files):
                d.addCallbacks(lambda _: client.get_root(), client.test_fail)
                d.addCallbacks(
                    lambda root: client.make_file(request.ROOT, root,
                                                  filenames.next()),
                    client.test_fail)
                d.addCallbacks(
                    lambda mkfile_req: client.put_content(
                        request.ROOT,
                        mkfile_req.new_id, NO_CONTENT_HASH, hash_value,
                        crc32_value, size, deflated_size,
                        StringIO(deflated_data)),
                    client.test_fail)
            d.addCallback(check_file)
            d.addCallbacks(client.test_done, client.test_fail)
            return d
        def auth(client):

            def check_file(result):

                @transaction.atomic
                def _check_file():
                    content_blob = services.get_object_or_none(
                        ContentBlob, hash=hash_value)
                    if not content_blob:
                        raise ValueError("content blob is not there")

                d = threads.deferToThread(_check_file)
                return d

            d = client.dummy_authenticate("open sesame")
            filename = 'hola_1'
            d.addCallbacks(lambda _: client.get_root(), client.test_fail)
            d.addCallbacks(
                lambda root: client.make_file(request.ROOT, root, filename),
                client.test_fail)

            def set_write_limit(r):
                client.factory.factory.writeLimit = 100
                return r

            d.addCallback(set_write_limit)
            d.addCallbacks(
                lambda mkfile_req: client.put_content(
                    request.ROOT, mkfile_req.new_id, NO_CONTENT_HASH,
                    hash_value, crc32_value, size, deflated_size,
                    StringIO(deflated_data)),
                client.test_fail)
            return d
Exemplo n.º 4
0
        def auth(client):
            def check_file(result):
                def _check_file():
                    storage_tm.begin()
                    try:
                        store = get_storage_store()
                        content_blob = store.get(model.ContentBlob, hash_value)
                        if not content_blob:
                            raise ValueError("content blob is not there")
                    finally:
                        storage_tm.abort()

                d = threads.deferToThread(_check_file)
                return d

            d = client.dummy_authenticate("open sesame")
            filename = 'hola_1'
            d.addCallbacks(lambda _: client.get_root(), client.test_fail)
            d.addCallbacks(
                lambda root: client.make_file(request.ROOT, root, filename),
                client.test_fail)

            def set_write_limit(r):
                client.factory.factory.writeLimit = 100
                return r

            d.addCallback(set_write_limit)
            d.addCallbacks(
                lambda mkfile_req: client.
                put_content(request.ROOT, mkfile_req.new_id, NO_CONTENT_HASH,
                            hash_value, crc32_value, size, deflated_size,
                            StringIO(deflated_data)), client.test_fail)
            return d
Exemplo n.º 5
0
        def auth(client):
            def check_file(result):
                def _check_file():
                    storage_tm.begin()
                    try:
                        store = get_storage_store()
                        content_blob = store.get(model.ContentBlob, hash_value)
                        if not content_blob:
                            raise ValueError("content blob is not there")
                    finally:

                        storage_tm.abort()

                d = threads.deferToThread(_check_file)
                return d

            d = client.dummy_authenticate("open sesame")
            filenames = iter('hola_%d' % i for i in xrange(num_files))
            for i in range(num_files):
                d.addCallbacks(lambda _: client.get_root(), client.test_fail)
                d.addCallbacks(
                    lambda root: client.make_file(request.ROOT, root,
                                                  filenames.next()),
                    client.test_fail)
                d.addCallbacks(
                    lambda mkfile_req: client.put_content(
                        request.ROOT, mkfile_req.new_id, NO_CONTENT_HASH,
                        hash_value, crc32_value, size, deflated_size,
                        StringIO(deflated_data)), client.test_fail)
            d.addCallback(check_file)
            d.addCallbacks(client.test_done, client.test_fail)
            return d
Exemplo n.º 6
0
        def auth(client):
            """Test."""
            yield client.dummy_authenticate("open sesame")
            root = yield client.get_root()

            # make a file and put content in it
            mkfile_req = yield client.make_file(request.ROOT, root, "hola")
            yield client.put_content(request.ROOT, mkfile_req.new_id,
                                     NO_CONTENT_HASH, hash_value, crc32_value,
                                     size, deflated_size,
                                     StringIO(deflated_data))

            # set the read limit, and get content
            client.factory.factory.readLimit = 1000
            yield client.get_content(request.ROOT, mkfile_req.new_id,
                                     hash_value)
Exemplo n.º 7
0
        def auth(client):
            """Test."""
            yield client.dummy_authenticate("open sesame")
            root = yield client.get_root()

            # make a file and put content in it
            mkfile_req = yield client.make_file(request.ROOT, root, "hola")
            yield client.put_content(request.ROOT, mkfile_req.new_id,
                                     NO_CONTENT_HASH, hash_value, crc32_value,
                                     size, deflated_size,
                                     StringIO(deflated_data))

            # set the read limit, and get content
            client.factory.factory.readLimit = 1000
            yield client.get_content(request.ROOT, mkfile_req.new_id,
                                     hash_value)
Exemplo n.º 8
0
 def auth(client):
     d = client.dummy_authenticate("open sesame")
     d.addCallbacks(lambda _: client.get_root(), client.test_fail)
     d.addCallbacks(
         lambda root: client.make_file(request.ROOT, root, "hola"),
         client.test_fail)
     d.addCallback(self.save_req, 'req')
     d.addCallbacks(
         lambda mkfile_req: client.
         put_content(request.ROOT, mkfile_req.new_id, NO_CONTENT_HASH,
                     hash_value, crc32_value, size, deflated_size,
                     StringIO(deflated_data)), client.test_fail)
     d.addCallback(lambda _: client.get_content(
         request.ROOT, self._state.req.new_id, hash_value))
     if check_file_content:
         d.addCallback(check_file)
     d.addCallbacks(client.test_done, client.test_fail)
Exemplo n.º 9
0
 def auth(client):
     d = client.dummy_authenticate("open sesame")
     d.addCallbacks(lambda _: client.get_root(), client.test_fail)
     d.addCallbacks(
         lambda root: client.make_file(request.ROOT, root, "hola"),
         client.test_fail)
     d.addCallback(self.save_req, 'req')
     d.addCallbacks(
         lambda mkfile_req: client.put_content(
             request.ROOT,
             mkfile_req.new_id, NO_CONTENT_HASH, hash_value,
             crc32_value, size, deflated_size, StringIO(deflated_data)),
         client.test_fail)
     d.addCallback(lambda _: client.get_content(
                   request.ROOT, self._state.req.new_id, hash_value))
     if check_file_content:
         d.addCallback(check_file)
     d.addCallbacks(client.test_done, client.test_fail)
Exemplo n.º 10
0
        def auth(client):
            def check_file(result):
                def _check_file():
                    filesync_tm.begin()
                    try:
                        store = get_filesync_store()
                        content_blob = store.get(ContentBlob, hash_value)
                        if not content_blob:
                            raise ValueError("content blob is not there")
                    finally:
                        filesync_tm.abort()

                d = threads.deferToThread(_check_file)
                return d

            d = client.dummy_authenticate("open sesame")
            filename = "hola_1"
            d.addCallbacks(lambda _: client.get_root(), client.test_fail)
            d.addCallbacks(lambda root: client.make_file(request.ROOT, root, filename), client.test_fail)

            def set_write_limit(r):
                client.factory.factory.writeLimit = 100
                return r

            d.addCallback(set_write_limit)
            d.addCallbacks(
                lambda mkfile_req: client.put_content(
                    request.ROOT,
                    mkfile_req.new_id,
                    NO_CONTENT_HASH,
                    hash_value,
                    crc32_value,
                    size,
                    deflated_size,
                    StringIO(deflated_data),
                ),
                client.test_fail,
            )
            return d