Back to index

plone3  3.1.7
Public Member Functions | Private Attributes
ExtendedPathIndex.tests.testExtendedPathIndex.TestExtendedPathIndex Class Reference
Inheritance diagram for ExtendedPathIndex.tests.testExtendedPathIndex.TestExtendedPathIndex:
Inheritance graph
[legend]
Collaboration diagram for ExtendedPathIndex.tests.testExtendedPathIndex.TestExtendedPathIndex:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def testIndexIntegrity
def testUnIndexError
def testDepthLimit
def testDefaultNavtree
def testShallowNavtree
def testNonexistingPaths
def testEmptyFolderDepthOne
def testSiteMap
def testBreadCrumbsWithStart
def testNegativeDepthQuery
def testPhysicalPathOptimization

Private Attributes

 _values

Detailed Description

Test ExtendedPathIndex objects 

Definition at line 150 of file testExtendedPathIndex.py.


Member Function Documentation

Definition at line 294 of file testExtendedPathIndex.py.

00294 
00295     def testBreadCrumbsWithStart(self):
00296         self._populateIndex()
00297         # Adding a navtree_start > 0 to a breadcrumb search should generate
00298         # breadcrumbs back to that level above the root.  The given path
00299         # will always be included, i.e. start > cur_level -> start = cur_level
00300         tests = [
00301             ('/'                   ,0,1,1,[]),
00302             ('/aa'                 ,0,1,1,[8]),
00303             ('/aa/aa'              ,0,1,1,[8]),
00304             ('/aa/aa/aa'           ,0,1,1,[8]),
00305             ('/aa/bb'              ,0,1,1,[8,9]),
00306             ('/bb'                 ,0,1,1,[16]),
00307             ('/bb/aa'              ,0,1,1,[16,18]),
00308             ('/bb/aa'              ,0,1,2,[18]),
00309             ('/bb/bb'              ,0,1,1,[16,17]),
00310             ('/bb/bb'              ,0,1,2,[17]),
00311             ('/bb/bb/bb/12.html'   ,0,1,1,[12,16,17]),
00312             ('/bb/bb/bb/12.html'   ,0,1,2,[12,17]),
00313             ('/bb/bb/bb/12.html'   ,0,1,3,[12]),
00314             ]
00315         for path, depth, navtree, navtree_start, results in tests:
00316             res = self._index._apply_index(
00317                 {"path": {'query': path,  "depth": depth, "navtree": navtree,
00318                                               "navtree_start":navtree_start}})
00319             lst = list(res[0].keys())
00320             self.assertEqual(lst,results,
00321                         '%s != %s Failed on %s start %s'%(
00322                                                lst,results,path,navtree_start))

Here is the call graph for this function:

Definition at line 184 of file testExtendedPathIndex.py.

00184 
00185     def testDefaultNavtree(self):
00186         self._populateIndex()
00187         # depth = 1 by default when using navtree
00188         tests = [
00189             ('/'        ,0,1,1,[1,8,16]),
00190             ('/aa'      ,0,1,1,[1,2,8,9,16]),
00191             ('/aa'      ,1,1,1,[2,3,9,10,13,17,18]),
00192             ('/aa/aa'   ,0,1,1,[1,2,3,8,9,16]),
00193             ('/aa/aa/aa',0,1,1,[1,2,3,4,8,9,16]),
00194             ('/aa/bb'   ,0,1,1,[1,2,5,8,9,16]),
00195             ('/bb'      ,0,1,1,[1,8,10,16,17,18]),
00196             ('/bb/aa'   ,0,1,1,[1,8,10,13,16,17,18]),
00197             ('/bb/bb'   ,0,1,1,[1,8,10,11,16,17,18]),
00198             ]
00199         for lst, level, depth, navtree, results in tests:
00200             res = self._index._apply_index(
00201                 {"path": {'query': lst, "level": level, "depth": depth, "navtree": navtree}})
00202             lst = list(res[0].keys())
00203             self.assertEqual(lst,results)

Here is the call graph for this function:

Definition at line 170 of file testExtendedPathIndex.py.

00170 
00171     def testDepthLimit(self):
00172         self._populateIndex()
00173         tests = [
00174             ('/', 0, 1, 0, [1,8,16]),
00175             ('/', 0, 2, 0, [1,2,8,9,10,16,17,18]),
00176             ('/', 0, 3, 0, [1,2,3,5,8,9,10,11,13,16,17,18]),
00177             ]
00178 
00179         for lst, level, depth, navtree, results in tests:
00180             res = self._index._apply_index(
00181                 {"path": {'query': lst, "level": level, "depth": depth, "navtree": navtree}})
00182             lst = list(res[0].keys())
00183             self.assertEqual(lst, results)

Here is the call graph for this function:

Definition at line 247 of file testExtendedPathIndex.py.

00247 
00248     def testEmptyFolderDepthOne(self):
00249         # Shouldn't return folder when we want children of empty folder
00250         self._values = {
00251           1 : epitc.Dummy("/portal/emptyfolder"),
00252           2 : epitc.Dummy("/portal/folder"),
00253           3 : epitc.Dummy("/portal/folder/document"),
00254           4 : epitc.Dummy("/portal/folder/subfolder"),
00255           5 : epitc.Dummy("/portal/folder/subfolder/newsitem")
00256           }
00257         self._populateIndex()
00258         tests = [
00259             ('/portal/folder'                       ,0,1,0,[3,4]),
00260             ('/portal/emptyfolder'                  ,0,1,0,[]),
00261             ('/portal/folder/document'              ,0,1,0,[]),
00262             ('/portal/folder/subfolder'             ,0,1,0,[5]),
00263             ('/portal/folder/subfolder/newsitem'    ,0,1,0,[]),
00264             ]
00265         for lst, level, depth, navtree, results in tests:
00266             res = self._index._apply_index(
00267                 {"path": {'query': lst, "level": level, "depth": depth, "navtree": navtree}})
00268             lst = list(res[0].keys())
00269             self.assertEqual(lst,results)

Definition at line 153 of file testExtendedPathIndex.py.

00153 
00154     def testIndexIntegrity(self):
00155         self._populateIndex()
00156         index = self._index._index
00157         self.assertEqual(list(index[None][0].keys()), [1,8,16])
00158         self.assertEqual(list(index[None][1].keys()), [2,9,10,17,18])
00159         self.assertEqual(list(index[None][2].keys()), [3,5,11,13])
00160         self.assertEqual(list(index[None][3].keys()), [4,6,7,12,14,15])

Here is the call graph for this function:

Definition at line 323 of file testExtendedPathIndex.py.

00323 
00324     def testNegativeDepthQuery(self):
00325         self._populateIndex()
00326         tests = [
00327             ('/'                   ,0,-1,0,range(1,19)), # Depth -1
00328             ('/aa'                 ,0,-1,0,[2,3,4,5,6,7,8,9]),
00329             ('/aa/aa'              ,0,-1,0,[3,4]),
00330             ('/aa/bb'              ,0,-1,0,[5,6,7,9]),
00331             ('/bb'                 ,0,-1,0,[10,11,12,13,14,15,16,17,18]),
00332             ('/bb/aa'              ,0,-1,0,[13,14,18]),
00333             ('/bb/bb'              ,0,-1,0,[11,12,15,17]),
00334         ]
00335 
00336         for path, level, depth, navtree, results in tests:
00337             res = self._index._apply_index(
00338                 {"path": {'query': path, "level": level, "depth": depth, "navtree": navtree}})
00339             lst = list(res[0].keys())
00340             self.assertEqual(lst,results,
00341                         '%s != %s Failed on %s level %s depth %s navtree %s'%(
00342                                         lst,results,path,level,depth,navtree))

Here is the call graph for this function:

Definition at line 225 of file testExtendedPathIndex.py.

00225 
00226     def testNonexistingPaths(self):
00227         self._populateIndex()
00228         # With depth 0 we only get the parents
00229         # When getting non existing paths, 
00230         # we should get as many parents as possible when building navtree
00231         tests = [
00232             ('/'        ,0,0,1,[]),
00233             ('/aa'      ,0,0,1,[8]), # Exists
00234             ('/aa/x'    ,0,0,1,[8]), # Doesn't exist
00235             ('/aa'      ,1,0,1,[18]),
00236             ('/aa/x'    ,1,0,1,[18]),
00237             ('/aa/aa'   ,0,0,1,[8]),
00238             ('/aa/aa/x' ,0,0,1,[8]),
00239             ('/aa/bb'   ,0,0,1,[8,9]),
00240             ('/aa/bb/x' ,0,0,1,[8,9]),
00241             ]
00242         for lst, level, depth, navtree, results in tests:
00243             res = self._index._apply_index(
00244                 {"path": {'query': lst, "level": level, "depth": depth, "navtree": navtree}})
00245             lst = list(res[0].keys())
00246             self.assertEqual(lst,results)

Here is the call graph for this function:

Definition at line 343 of file testExtendedPathIndex.py.

00343 
00344     def testPhysicalPathOptimization(self):
00345         self._populateIndex()
00346         # Fake a physical path for the index
00347         self._index.old_getPhysicalPath = self._index.getPhysicalPath
00348         self._index.getPhysicalPath = lambda: ('','aa')
00349         self.assertEqual(self._index.getPhysicalPath(), ('','aa'))
00350         # Test a variety of arguments
00351         tests = [
00352             ('/'                   ,0,1,0,[1,8,16]), # Sitemap
00353             ('/'                   ,0,0,1,[]), # Non-Existant
00354             ('/'                   ,0,0,1,[]), # Breadcrumb tests
00355             ('/aa'                 ,0,0,1,[8]),
00356             ('/aa/aa'              ,0,0,1,[8]),
00357             ('/'                   ,0,1,1,[1,8,16]), # Navtree tests
00358             ('/aa'                 ,0,1,1,[1,2,8,9,16]),
00359             ('/aa/aa'              ,0,1,1,[1,2,3,8,9,16]),
00360             ('/'                   ,0,0,0,[]), # Depth Zero tests
00361             ('/aa'                 ,0,0,0,[8]),
00362             ('/aa/aa'              ,0,0,0,[]),
00363             ('/'                   ,0,-1,0,range(1,19)), # Depth -1
00364             ('/aa'                 ,0,-1,0,range(1,19)), # Should assume that
00365                                                          # all paths are
00366                                                          # relevant
00367         ]
00368 
00369         for path, level, depth, navtree, results in tests:
00370             res = self._index._apply_index(
00371                 {"path": {'query': path, "level": level, "depth": depth, "navtree": navtree}})
00372             lst = list(res[0].keys())
00373             self.assertEqual(lst,results,
00374                         '%s != %s Failed on %s level %s depth %s navtree %s'%(
00375                                         lst,results,path,level,depth,navtree))
00376 
00377         self._index.getPhysicalPath = self._index.old_getPhysicalPath
00378         self.assertEqual(self._index.getPhysicalPath(), ('path',))
00379 

Here is the call graph for this function:

Definition at line 204 of file testExtendedPathIndex.py.

00204 
00205     def testShallowNavtree(self):
00206         self._populateIndex()
00207         # With depth 0 we only get the parents
00208         tests = [
00209             ('/'        ,0,0,1,[]),
00210             ('/aa'      ,0,0,1,[8]),
00211             ('/aa'      ,1,0,1,[18]),
00212             ('/aa/aa'   ,0,0,1,[8]),
00213             ('/aa/aa/aa',0,0,1,[8]),
00214             ('/aa/bb'   ,0,0,1,[8,9]),
00215             ('/bb'      ,0,0,1,[16]),
00216             ('/bb/aa'   ,0,0,1,[16,18]),
00217             ('/bb/bb'   ,0,0,1,[16,17]),
00218             ('/bb/bb/aa'   ,0,0,1,[16,17]),
00219             ]
00220         for lst, level, depth, navtree, results in tests:
00221             res = self._index._apply_index(
00222                 {"path": {'query': lst, "level": level, "depth": depth, "navtree": navtree}})
00223             lst = list(res[0].keys())
00224             self.assertEqual(lst,results)

Here is the call graph for this function:

Definition at line 270 of file testExtendedPathIndex.py.

00270 
00271     def testSiteMap(self):
00272         self._values = {
00273           1 : epitc.Dummy("/portal/emptyfolder"),
00274           2 : epitc.Dummy("/portal/folder"),
00275           3 : epitc.Dummy("/portal/folder/document"),
00276           4 : epitc.Dummy("/portal/folder/subfolder"),
00277           5 : epitc.Dummy("/portal/folder/subfolder/newsitem")
00278           }
00279         self._populateIndex()
00280         tests = [
00281             ('/' ,0,1,0,[]),
00282             ('/' ,0,2,0,[1,2]),
00283             ('/' ,0,3,0,[1,2,3,4]),
00284             ('/' ,0,4,0,[1,2,3,4,5]),
00285             ('/' ,0,5,0,[1,2,3,4,5]),
00286             ('/' ,0,6,0,[1,2,3,4,5]),
00287             ]
00288         for lst, level, depth, navtree, results in tests:
00289             res = self._index._apply_index(
00290                 {"path": {'query': lst, "level": level, "depth": depth, "navtree": navtree}})
00291             lst = list(res[0].keys())
00292             self.assertEqual(lst,results)
00293 

Here is the call graph for this function:

Definition at line 161 of file testExtendedPathIndex.py.

00161 
00162     def testUnIndexError(self):
00163         self._populateIndex()
00164         # this should not raise an error
00165         self._index.unindex_object(-1)
00166 
00167         # nor should this
00168         self._index._unindex[1] = "/broken/thing"
00169         self._index.unindex_object(1)

Here is the call graph for this function:


Member Data Documentation


The documentation for this class was generated from the following file: