Example #1
0
File: epitc.py Project: dtgit/dtedu
class PathIndexTestCase(ZopeTestCase.ZopeTestCase):

    def _setup(self):
        self._index = ExtendedPathIndex( 'path' )
        self._values = {
          1 : Dummy("/aa/aa/aa/1.html"),
          2 : Dummy("/aa/aa/bb/2.html"),
          3 : Dummy("/aa/aa/cc/3.html"),
          4 : Dummy("/aa/bb/aa/4.html"),
          5 : Dummy("/aa/bb/bb/5.html"),
          6 : Dummy("/aa/bb/cc/6.html"),
          7 : Dummy("/aa/cc/aa/7.html"),
          8 : Dummy("/aa/cc/bb/8.html"),
          9 : Dummy("/aa/cc/cc/9.html"),
          10 : Dummy("/bb/aa/aa/10.html"),
          11 : Dummy("/bb/aa/bb/11.html"),
          12 : Dummy("/bb/aa/cc/12.html"),
          13 : Dummy("/bb/bb/aa/13.html"),
          14 : Dummy("/bb/bb/bb/14.html"),
          15 : Dummy("/bb/bb/cc/15.html"),
          16 : Dummy("/bb/cc/aa/16.html"),
          17 : Dummy("/bb/cc/bb/17.html"),
          18 : Dummy("/bb/cc/cc/18.html")
        }

    def _populateIndex(self):
        for k, v in self._values.items():
            self._index.index_object( k, v )
Example #2
0
    def setUp(self):
        """Custom setup for tests."""
        self.portal = self.layer['portal']

        from plone.app.vocabularies.tests import base
        context = base.create_context()
        rids = ('1', '2',)
        tool = base.DummyCatalog(rids)
        context.portal_catalog = tool
        context.portal_url = base.DummyUrlTool(context)

        from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex  # noqa
        kwindex = KeywordIndex('Subject')
        tool.indexes['Subject'] = kwindex
        from Products.ExtendedPathIndex.ExtendedPathIndex import ExtendedPathIndex  # noqa
        pathindex = ExtendedPathIndex('path')
        tool.indexes['path'] = pathindex

        self.subjects_1 = ['Berlin', 'Wien', 'Paris', 'Barcelona']
        self.subjects_2 = ['Montreal', 'Washington', 'Brasilia']

        self.navroot1 = base.DummyContentWithParent('nr1', parent=context)
        alsoProvides(self.navroot1, INavigationRoot)
        self.navroot2 = base.DummyContentWithParent('nr2', parent=context)
        alsoProvides(self.navroot2, INavigationRoot)

        self.doc1 = base.DummyContentWithParent(
            'doc1',
            subjects=self.subjects_1,
            parent=self.navroot1
        )
        kwindex._index_object(1, self.doc1, attr='Subject')
        pathindex.index_object(1, self.doc1)

        self.doc2 = base.DummyContentWithParent(
            'doc2',
            subjects=self.subjects_2,
            parent=self.navroot2
        )
        kwindex._index_object(2, self.doc2, attr='Subject')
        pathindex.index_object(2, self.doc2)

        from plone.app.vocabularies.catalog import KeywordsVocabulary
        self.vocab = KeywordsVocabulary()

        # mock our registry
        from plone.registry import Registry
        from plone.registry.interfaces import IRegistry
        from zope.component import getSiteManager
        sm = getSiteManager()
        from Products.CMFCore.interfaces import ICatalogTool
        sm.registerUtility(tool, ICatalogTool)
        registry = Registry()
        sm.registerUtility(registry, IRegistry)
        from Products.CMFCore.interfaces import IURLTool
        sm.registerUtility(context.portal_url, IURLTool)
        registry_patcher = mock.patch('plone.registry.registry.Registry.get')
        self.addCleanup(registry_patcher.stop)
        self.registry_mock = registry_patcher.start()
Example #3
0
File: epitc.py Project: dtgit/dtedu
 def _setup(self):
     self._index = ExtendedPathIndex( 'path' )
     self._values = {
       1 : Dummy("/aa/aa/aa/1.html"),
       2 : Dummy("/aa/aa/bb/2.html"),
       3 : Dummy("/aa/aa/cc/3.html"),
       4 : Dummy("/aa/bb/aa/4.html"),
       5 : Dummy("/aa/bb/bb/5.html"),
       6 : Dummy("/aa/bb/cc/6.html"),
       7 : Dummy("/aa/cc/aa/7.html"),
       8 : Dummy("/aa/cc/bb/8.html"),
       9 : Dummy("/aa/cc/cc/9.html"),
       10 : Dummy("/bb/aa/aa/10.html"),
       11 : Dummy("/bb/aa/bb/11.html"),
       12 : Dummy("/bb/aa/cc/12.html"),
       13 : Dummy("/bb/bb/aa/13.html"),
       14 : Dummy("/bb/bb/bb/14.html"),
       15 : Dummy("/bb/bb/cc/15.html"),
       16 : Dummy("/bb/cc/aa/16.html"),
       17 : Dummy("/bb/cc/bb/17.html"),
       18 : Dummy("/bb/cc/cc/18.html")
     }