Пример #1
0
class TestIOIndex(IndicoTestCase):

    def setUp(self):
        super(TestIOIndex, self).setUp()
        self._idx = IOIndex(IDummyAdapter)

    def _indexSomeElements(self):
        objs = []
        for i in range(0, 200):
            obj = DummyObject(i)
            objs.append(obj)
            self._idx.index_obj(obj)

        return objs

    def testIndexing(self):
        objs = self._indexSomeElements()

        self.assertEqual(list(self._idx[1]), objs[10:20])
        self.assertEqual(len(self._idx), 200)

    def testFwdIndex(self):
        objs = self._indexSomeElements()
        for i in range(0, 200):
            self.assertTrue(objs[i] in self._idx._fwd_index[i/10])

    def testRevIndex(self):
        self._indexSomeElements()
        for i in range(0, 200):
            self.assertEqual(list(self._idx._rev_index[i]), [i/10])

    def testUnindexing(self):
        objs = self._indexSomeElements()

        for obj in objs:
            self._idx.unindex_obj(obj)

        self.assertEqual(len(self._idx), 0)

        for i in range(0, 20):
            self.assertEqual(self._idx.get(i), None)

    def testUnindexingNonExisting(self):
        self.assertRaises(ElementNotFoundException,
                          self._idx.unindex_obj,
                          DummyObject(1))

    def testIndexingTwice(self):
        obj = DummyObject(1)
        self._idx.index_obj(obj)
        self.assertRaises(ElementAlreadyInIndexException,
                          self._idx.index_obj,
                          obj)
Пример #2
0
 def _initializeSubIndex(self, cset):
     tsIndex = IOIndex(IIndexableByStartDateTime)
     for conf in cset:
         tsIndex.index_obj(conf)
     return tsIndex
Пример #3
0
 def setUp(self):
     super(TestIOIndex, self).setUp()
     self._idx = IOIndex(IDummyAdapter)
Пример #4
0
 def _initializeSubIndex(self, cset):
     tsIndex = IOIndex(IIndexableByStartDateTime)
     for conf in cset:
         tsIndex.index_obj(conf)
     return tsIndex
Пример #5
0
 def add_category(self, categId):
     self._container[categId] = IOIndex(IIndexableByStartDateTime)
Пример #6
0
 def setUp(self):
     self._idx = IOIndex(IDummyAdapter)
Пример #7
0
 def setUp(self):
     self._idx = IOIndex(IDummyAdapter)