Ejemplo n.º 1
0
 def __init__(self, context, schema=None):
     self._context_uid = IUUID(context)
     if schema is None:
         schema = getattr(context, 'schema', None)
         if schema is None:
             raise ValueError('Context does not provide schema')
     self.indexer = Indexer()
     self.uidmap = UUIDMapper()
     self.bind(schema)
Ejemplo n.º 2
0
 def _test_index(self, cls, getter):
     indexer = Indexer()
     idx = cls(getter)
     idx.index_doc(1, MockItem())
     idx.index_doc(indexer.family.maxint, MockItem())
     self.assertRaises(
         ValueError,
         idx.index_doc,
         indexer.family.maxint + 1,  # too big
         MockItem(),
     )
Ejemplo n.º 3
0
 def test_docid(self):
     import random
     indexer = Indexer()
     _random = lambda o, default: random.randint(0, 1111)
     idx1 = FieldIndex(_random)
     indexer['idx1'] = idx1
     indexer.index_doc(1, MockItem())
     indexer.index_doc(indexer.family.maxint, MockItem())
     self.assertRaises(
         ValueError,
         indexer.index_doc,
         indexer.family.maxint + 1,
         MockItem(),
     )