Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
ExtendedPathIndex.tests.testIndexedAttrs.TestIndexedAttrs Class Reference

List of all members.

Public Member Functions

def afterSetUp
def addIndex
def testAddIndex
def testDefaultIndexedAttrs
def testDefaultIndexSourceNames
def testDefaultIndexObject
def testDefaultSearchObject
def testDefaultSearchDictSyntax
def testExtraAsRecord
def testExtraAsMapping
def testCustomIndexSourceNames
def testCustomIndexObject
def testCustomSearchObject
def testStringIndexObject
def testStringSearchObject
def testIdIndexObject
def testIdIndexObject
def testListIndexedAttr
def testStringIndexedAttr
def testEmtpyListAttr
def testEmtpyStringAttr

Public Attributes

 catalog
 dummy
 physical_path
 custom_path
 string_path

Detailed Description

Definition at line 30 of file testIndexedAttrs.py.


Member Function Documentation

def ExtendedPathIndex.tests.testIndexedAttrs.TestIndexedAttrs.addIndex (   self,
  id = 'path',
  extra = None 
)

Definition at line 40 of file testIndexedAttrs.py.

00040 
00041     def addIndex(self, id='path', extra=None):
00042         self.catalog.addIndex(id, 'ExtendedPathIndex', extra)
00043         return self.catalog.Indexes[id]

Here is the caller graph for this function:

Definition at line 32 of file testIndexedAttrs.py.

00032 
00033     def afterSetUp(self):
00034         self.catalog = ZCatalog('catalog')
00035         self.folder._setObject('dummy', Dummy('dummy'))
00036         self.dummy = self.folder.dummy
00037         self.physical_path = '/'.join(self.dummy.getPhysicalPath())
00038         self.custom_path = '/'.join(self.dummy.getCustomPath())
00039         self.string_path = self.dummy.getStringPath()

Definition at line 44 of file testIndexedAttrs.py.

00044 
00045     def testAddIndex(self):
00046         self.catalog.addIndex('path', 'ExtendedPathIndex')
00047         try:
00048             self.catalog.Indexes['path']
00049         except KeyError:
00050             self.fail('Failed to create index')

Here is the call graph for this function:

Definition at line 94 of file testIndexedAttrs.py.

00094 
00095     def testCustomIndexObject(self):
00096         # PathIndex indexes getCustomPath
00097         idx = self.addIndex(extra={'indexed_attrs': 'getCustomPath'})
00098         idx.index_object(123, self.dummy)
00099         self.assertEqual(idx.getEntryForObject(123), self.custom_path)

Here is the call graph for this function:

Definition at line 89 of file testIndexedAttrs.py.

00089 
00090     def testCustomIndexSourceNames(self):
00091         # getIndexSourceName returns the indexed_attrs
00092         idx = self.addIndex(extra={'indexed_attrs': 'getCustomPath'})
00093         self.assertEqual(idx.getIndexSourceNames(), ('getCustomPath',))

Here is the call graph for this function:

Definition at line 100 of file testIndexedAttrs.py.

00100 
00101     def testCustomSearchObject(self):
00102         # We can find the object in the catalog by custom path
00103         self.addIndex(extra={'indexed_attrs': 'getCustomPath'})
00104         self.catalog.catalog_object(self.dummy)
00105         self.assertEqual(len(self.catalog(path=self.custom_path)), 1)

Here is the call graph for this function:

Definition at line 51 of file testIndexedAttrs.py.

00051 
00052     def testDefaultIndexedAttrs(self):
00053         # By default we don't have indexed_attrs at all
00054         idx = self.addIndex()
00055         self.failIf(hasattr(idx, 'indexed_attrs'))

Here is the call graph for this function:

Definition at line 61 of file testIndexedAttrs.py.

00061 
00062     def testDefaultIndexObject(self):
00063         # By default PathIndex indexes getPhysicalPath
00064         idx = self.addIndex()
00065         idx.index_object(123, self.dummy)
00066         self.assertEqual(idx.getEntryForObject(123), self.physical_path)

Here is the call graph for this function:

Definition at line 56 of file testIndexedAttrs.py.

00056 
00057     def testDefaultIndexSourceNames(self):
00058         # However, getIndexSourceName returns 'getPhysicalPath'
00059         idx = self.addIndex()
00060         self.assertEqual(idx.getIndexSourceNames(), ('getPhysicalPath',))

Here is the call graph for this function:

Definition at line 73 of file testIndexedAttrs.py.

00073 
00074     def testDefaultSearchDictSyntax(self):
00075         # PathIndex supports dictionary syntax for queries
00076         self.addIndex()
00077         self.catalog.catalog_object(self.dummy)
00078         self.assertEqual(len(self.catalog(path={'query': self.physical_path})), 1)

Here is the call graph for this function:

Definition at line 67 of file testIndexedAttrs.py.

00067 
00068     def testDefaultSearchObject(self):
00069         # We can find the object in the catalog by physical path
00070         self.addIndex()
00071         self.catalog.catalog_object(self.dummy)
00072         self.assertEqual(len(self.catalog(path=self.physical_path)), 1)

Here is the call graph for this function:

Definition at line 142 of file testIndexedAttrs.py.

00142 
00143     def testEmtpyListAttr(self):
00144         # Empty indexed_attrs falls back to defaults
00145         idx = self.addIndex(extra={'indexed_attrs': []})
00146         self.assertEqual(idx.getIndexSourceNames(), ('getPhysicalPath',))

Here is the call graph for this function:

Definition at line 147 of file testIndexedAttrs.py.

00147 
00148     def testEmtpyStringAttr(self):
00149         # Empty indexed_attrs falls back to defaults
00150         idx = self.addIndex(extra={'indexed_attrs': ''})
00151         self.assertEqual(idx.getIndexSourceNames(), ('getPhysicalPath',))
00152 

Here is the call graph for this function:

Definition at line 84 of file testIndexedAttrs.py.

00084 
00085     def testExtraAsMapping(self):
00086         # or a dictionary
00087         idx = self.addIndex(extra={'indexed_attrs': 'getCustomPath'})
00088         self.assertEqual(idx.indexed_attrs, ('getCustomPath',))

Here is the call graph for this function:

Definition at line 79 of file testIndexedAttrs.py.

00079 
00080     def testExtraAsRecord(self):
00081         # 'extra' can be a record type object
00082         idx = self.addIndex(extra=Record(indexed_attrs='getCustomPath'))
00083         self.assertEqual(idx.indexed_attrs, ('getCustomPath',))

Here is the call graph for this function:

Definition at line 118 of file testIndexedAttrs.py.

00118 
00119     def testIdIndexObject(self):
00120         # PathIndex prefers an attribute matching its id over getPhysicalPath
00121         idx = self.addIndex(id='getId')
00122         idx.index_object(123, self.dummy)
00123         self.assertEqual(idx.getEntryForObject(123), 'dummy')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 124 of file testIndexedAttrs.py.

00124 
00125     def testIdIndexObject(self):
00126         # Using indexed_attr overrides this behavior
00127         idx = self.addIndex(id='getId', extra={'indexed_attrs': 'getCustomPath'})
00128         idx.index_object(123, self.dummy)
00129         self.assertEqual(idx.getEntryForObject(123), self.custom_path)

Here is the call graph for this function:

Definition at line 130 of file testIndexedAttrs.py.

00130 
00131     def testListIndexedAttr(self):
00132         # indexed_attrs can be a list
00133         idx = self.addIndex(id='getId', extra={'indexed_attrs': ['getCustomPath', 'foo']})
00134         # only the first attribute is used
00135         self.assertEqual(idx.getIndexSourceNames(), ('getCustomPath',))

Here is the call graph for this function:

Definition at line 136 of file testIndexedAttrs.py.

00136 
00137     def testStringIndexedAttr(self):
00138         # indexed_attrs can also be a comma separated string
00139         idx = self.addIndex(id='getId', extra={'indexed_attrs': 'getCustomPath, foo'})
00140         # only the first attribute is used
00141         self.assertEqual(idx.getIndexSourceNames(), ('getCustomPath',))

Here is the call graph for this function:

Definition at line 106 of file testIndexedAttrs.py.

00106 
00107     def testStringIndexObject(self):
00108         # PathIndex accepts a path as tuple or string
00109         idx = self.addIndex(extra={'indexed_attrs': 'getStringPath'})
00110         idx.index_object(123, self.dummy)
00111         self.assertEqual(idx.getEntryForObject(123), self.string_path)

Here is the call graph for this function:

Definition at line 112 of file testIndexedAttrs.py.

00112 
00113     def testStringSearchObject(self):
00114         # And we can find the object in the catalog again
00115         self.addIndex(extra={'indexed_attrs': 'getStringPath'})
00116         self.catalog.catalog_object(self.dummy)
00117         self.assertEqual(len(self.catalog(path=self.string_path)), 1)

Here is the call graph for this function:


Member Data Documentation

Definition at line 33 of file testIndexedAttrs.py.

Definition at line 37 of file testIndexedAttrs.py.

Definition at line 35 of file testIndexedAttrs.py.

Definition at line 36 of file testIndexedAttrs.py.

Definition at line 38 of file testIndexedAttrs.py.


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