def test_small_chunks(self):
        self.db.fs.files.remove({})
        self.db.fs.chunks.remove({})

        self.files = 0
        self.chunks = 0

        def helper(data):
            filename = qcheck.gen_printable_string(qcheck.lift(20))()

            f = GridFile({"filename": filename, "chunkSize": 1}, self.db, "w")
            f.write(data)
            f.close()

            self.files += 1
            self.chunks += len(data)

            self.assertEqual(self.db.fs.files.find().count(), self.files)
            self.assertEqual(self.db.fs.chunks.find().count(), self.chunks)

            f = GridFile({"filename": filename}, self.db)
            self.assertEqual(f.read(), data)
            f.close()

            f = GridFile({"filename": filename}, self.db)
            self.assertEqual(f.read(10) + f.read(10), data)
            f.close()
            return True

        qcheck.check_unittest(self, helper,
                              qcheck.gen_string(qcheck.gen_range(0, 20)))
    def test_small_chunks(self):
        self.files = 0
        self.chunks = 0

        def helper(data):
            f = GridIn(self.db.fs, chunkSize=1)
            f.write(data)
            f.close()

            self.files += 1
            self.chunks += len(data)

            self.assertEqual(self.files, self.db.fs.files.find().count())
            self.assertEqual(self.chunks, self.db.fs.chunks.find().count())

            g = GridOut(self.db.fs, f._id)
            self.assertEqual(data, g.read())

            g = GridOut(self.db.fs, f._id)
            self.assertEqual(data, g.read(10) + g.read(10))
            return True

        qcheck.check_unittest(self, helper,
                              qcheck.gen_string(qcheck.gen_range(0, 20)))
    def test_small_chunks(self):
        self.files = 0
        self.chunks = 0

        def helper(data):
            f = GridIn(self.db.fs, chunkSize=1)
            f.write(data)
            f.close()

            self.files += 1
            self.chunks += len(data)

            self.assertEqual(self.files, self.db.fs.files.find().count())
            self.assertEqual(self.chunks, self.db.fs.chunks.find().count())

            g = GridOut(self.db.fs, f._id)
            self.assertEqual(data, g.read())

            g = GridOut(self.db.fs, f._id)
            self.assertEqual(data, g.read(10) + g.read(10))
            return True

        qcheck.check_unittest(self, helper,
                              qcheck.gen_string(qcheck.gen_range(0, 20)))
示例#4
0
 def test_random_data_is_not_bson(self):
     qcheck.check_unittest(self, qcheck.isnt(is_valid),
                           qcheck.gen_string(qcheck.gen_range(0, 40)))
示例#5
0
 def test_random_data_is_not_bson(self):
     qcheck.check_unittest(self, qcheck.isnt(is_valid),
                           qcheck.gen_string(qcheck.gen_range(0, 40)))