Back to index

plone3  3.1.7
epitc.py
Go to the documentation of this file.
00001 from Testing import ZopeTestCase
00002 from Products.ExtendedPathIndex.ExtendedPathIndex import ExtendedPathIndex
00003 
00004 
00005 class Dummy:
00006 
00007     meta_type="foo"
00008 
00009     def __init__(self, path):
00010         self.path = path
00011 
00012     def getPhysicalPath(self):
00013         return self.path.split('/')
00014 
00015     def __str__(self):
00016         return '<Dummy: %s>' % self.path
00017 
00018     __repr__ = __str__
00019 
00020 
00021 class PathIndexTestCase(ZopeTestCase.ZopeTestCase):
00022 
00023     def _setup(self):
00024         self._index = ExtendedPathIndex( 'path' )
00025         self._values = {
00026           1 : Dummy("/aa/aa/aa/1.html"),
00027           2 : Dummy("/aa/aa/bb/2.html"),
00028           3 : Dummy("/aa/aa/cc/3.html"),
00029           4 : Dummy("/aa/bb/aa/4.html"),
00030           5 : Dummy("/aa/bb/bb/5.html"),
00031           6 : Dummy("/aa/bb/cc/6.html"),
00032           7 : Dummy("/aa/cc/aa/7.html"),
00033           8 : Dummy("/aa/cc/bb/8.html"),
00034           9 : Dummy("/aa/cc/cc/9.html"),
00035           10 : Dummy("/bb/aa/aa/10.html"),
00036           11 : Dummy("/bb/aa/bb/11.html"),
00037           12 : Dummy("/bb/aa/cc/12.html"),
00038           13 : Dummy("/bb/bb/aa/13.html"),
00039           14 : Dummy("/bb/bb/bb/14.html"),
00040           15 : Dummy("/bb/bb/cc/15.html"),
00041           16 : Dummy("/bb/cc/aa/16.html"),
00042           17 : Dummy("/bb/cc/bb/17.html"),
00043           18 : Dummy("/bb/cc/cc/18.html")
00044         }
00045 
00046     def _populateIndex(self):
00047         for k, v in self._values.items():
00048             self._index.index_object( k, v )
00049 
00050 
00051 class ExtendedPathIndexTestCase(PathIndexTestCase):
00052 
00053     def _setup(self):
00054         self._index = ExtendedPathIndex( 'path' )
00055         self._values = {
00056           1 : Dummy("/1.html"),
00057           2 : Dummy("/aa/2.html"),
00058           3 : Dummy("/aa/aa/3.html"),
00059           4 : Dummy("/aa/aa/aa/4.html"),
00060           5 : Dummy("/aa/bb/5.html"),
00061           6 : Dummy("/aa/bb/aa/6.html"),
00062           7 : Dummy("/aa/bb/bb/7.html"),
00063           8 : Dummy("/aa"),
00064           9 : Dummy("/aa/bb"),
00065           10 : Dummy("/bb/10.html"),
00066           11 : Dummy("/bb/bb/11.html"),
00067           12 : Dummy("/bb/bb/bb/12.html"),
00068           13 : Dummy("/bb/aa/13.html"),
00069           14 : Dummy("/bb/aa/aa/14.html"),
00070           15 : Dummy("/bb/bb/aa/15.html"),
00071           16 : Dummy("/bb"),
00072           17 : Dummy("/bb/bb"),
00073           18 : Dummy("/bb/aa")
00074         }
00075