def test_small_documents(self): key_gen = docgen.NewOrderedKey(prefix='test', fmtr='decimal') doc_gen = docgen.Document(avg_size=150) for i in range(10 ** 3): key = key_gen.next(i) doc = doc_gen.next(key=key) size = len(str(doc)) self.assertEqual(doc["body"], "") self.assertAlmostEqual(size, doc_gen.OVERHEAD, delta=20)
def test_doc_size_variation(self): size = 512 key_gen = docgen.NewOrderedKey(prefix='test', fmtr='decimal') doc_gen = docgen.Document(avg_size=size) for i in range(10 ** 4): key = key_gen.next(i) doc = doc_gen.next(key=key) actual_size = len(str(doc)) self.assertAlmostEqual(actual_size, size, delta=size * doc_gen.SIZE_VARIATION)