예제 #1
0
    def test_stream_to_handler(self):
        fs = motor.MotorGridFS(self.db)

        for content_length in (0, 1, 100, 100 * 1000):
            _id = yield fs.put(b'a' * content_length)
            gridout = yield fs.get(_id)
            handler = MockRequestHandler()
            yield gridout.stream_to_handler(handler)
            self.assertEqual(content_length, handler.n_written)
            yield fs.delete(_id)
예제 #2
0
    async def test_stream_to_handler(self):
        fs = motor.MotorGridFSBucket(self.db)

        for content_length in (0, 1, 100, 100 * 1000):
            _id = await fs.upload_from_stream('filename', b'a' * content_length)
            gridout = await fs.open_download_stream(_id)
            handler = MockRequestHandler()
            await gridout.stream_to_handler(handler)
            self.assertEqual(content_length, handler.n_written)
            await fs.delete(_id)