diff --git a/last_commit.txt b/last_commit.txt index 98a49b73ae..d568c0b66e 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,116 +1,1004 @@ -Repository: plone.app.blob +Repository: Products.ATContentTypes Branch: refs/heads/master -Date: 2017-02-21T22:14:58+01:00 +Date: 2017-02-20T12:40:50+01:00 Author: Gil Forcada (gforcada) -Commit: https://github.com/plone/plone.app.blob/commit/e85355ff7352643d4574412a826632d381f6de5c +Commit: https://github.com/plone/Products.ATContentTypes/commit/0fc25a0c1302c31a3e9efcbcb05ecb3fe6af37b4 -Process indexing operations +Adapt tests -Part of PLIP: https://github.com/plone/Products.CMFPlone/issues/1343 +With PLIP 1343 being merged some tests need to be adapted. + +Now the catalog no longer processes indexing operations right away. + +Some tests rely on that, so a minimal adaptation was needed. + +reindex_sanity.txt is removed because with collective.indexing the test +becomes unreadable or never passes. + +References: +https://github.com/plone/Products.CMFPlone/issues/1343 Files changed: M CHANGES.rst -M src/plone/app/blob/tests/test_maintenance.py +M Products/ATContentTypes/tests/test_criteria.py +M Products/ATContentTypes/tests/test_doctests.py +D Products/ATContentTypes/tests/reindex_sanity.txt diff --git a/CHANGES.rst b/CHANGES.rst -index ba237af..fd4a7a6 100644 +index ae28177..348d84a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -10,7 +10,9 @@ Breaking changes: +@@ -45,6 +45,10 @@ Bug fixes: - New features: + - Require plone.app.imaging even if Plone itself does not. [davisagli] --- *add item here* +- Adapt tests to the new indexing operations queueing. + Part of PLIP 1343: https://github.com/plone/Products.CMFPlone/issues/1343 + [gforcada] - - Bug fixes: - -diff --git a/src/plone/app/blob/tests/test_maintenance.py b/src/plone/app/blob/tests/test_maintenance.py -index a8c502d..6178de0 100644 ---- a/src/plone/app/blob/tests/test_maintenance.py -+++ b/src/plone/app/blob/tests/test_maintenance.py -@@ -4,6 +4,12 @@ - from Products.ATContentTypes.interface import file as atfile - from Products.ATContentTypes.interface import image as atimage - -+try: -+ from Products.CMFCore.indexing import processQueue -+except ImportError: -+ def processQueue(): -+ pass + - class MaintenanceViewTests(ReplacementTestCase): + 2.3 (2016-10-03) + ---------------- +diff --git a/Products/ATContentTypes/tests/reindex_sanity.txt b/Products/ATContentTypes/tests/reindex_sanity.txt +deleted file mode 100644 +index b28205f..0000000 +--- a/Products/ATContentTypes/tests/reindex_sanity.txt ++++ /dev/null +@@ -1,424 +0,0 @@ +-Reindex Sanity +-============== +- +-Those tests make sure that the catalog is only called as necessary. +- +- >>> import sys +- >>> from os.path import sep +- >>> from Products.ZCatalog.ZCatalog import ZCatalog +- >>> from Products.CMFCore.utils import getToolByName +- >>> from Products.Archetypes.utils import wrap_method +- >>> from Products.Archetypes.utils import unwrap_method +- >>> from Products.Archetypes.utils import call_original as call +- >>> from plone.app.testing import TEST_USER_NAME as default_user +- >>> from plone.app.testing import SITE_OWNER_NAME as portal_owner +- >>> import transaction +- +- >>> from plone.app.testing import TEST_USER_ID, setRoles +- >>> portal = layer['portal'] +- >>> setRoles(portal, TEST_USER_ID, ['Manager']) +- >>> folder = portal.portal_membership.getHomeFolder(TEST_USER_ID) +- +- >>> _ = folder.invokeFactory(type_name='Folder', id='sub') +- +- >>> def callers(n=1): +- ... stack = [] +- ... import inspect +- ... frames = inspect.getouterframes(inspect.currentframe()) +- ... fp = filter(None, sys.path) +- ... for i in range(n+1, 1, -1): +- ... try: +- ... frame = frames[i] +- ... except IndexError: +- ... continue +- ... fname, ln, func = frame[1:4] +- ... for p in fp: +- ... fname = fname.split(p)[-1] +- ... fname = fname.split('Products')[-1] +- ... fname = fname.split('.py')[0] +- ... fname = '.'.join(fname.strip(sep).split(sep)) +- ... stack.append(':'.join((fname, str(ln), func))) +- ... return stack +- +-Wrap ZCatalog methods to let us know about why and when they were called: +- +- >>> pattern = '__at_reindex_sanity_%s__' +- +- >>> def catalog_object(self, *args, **kw): +- ... rv = call(self, 'catalog_object', pattern, *args, **kw) +- ... print 'Catalog: ', self.getId() +- ... uid = kw.get('uid', None) +- ... if not uid: +- ... if len(args) > 1: +- ... uid = args[1] +- ... else: +- ... uid = '/'.join(args[0].getPhysicalPath()) +- ... idxs = kw.get('idxs', []) +- ... if not idxs: +- ... if len(args) > 2: +- ... idxs = args[2] +- ... print 'Indexing:', uid, idxs +- ... # The next line is usefull for debugging. +- ... # print 'Callers: ', '\n '.join(callers(15)) +- ... print '-' * 60 +- ... return rv +- +- >>> def uncatalog_object(self, *args, **kw): +- ... rv = call(self, 'uncatalog_object', pattern, *args, **kw) +- ... print 'Catalog: ', self.getId() +- ... print 'UnIndexing:', kw.get('uid', None) or args[0] +- ... # The next line is usefuld for debugging. +- ... # print 'Callers: ', '\n '.join(callers(15)) +- ... print '-' * 60 +- ... return rv +- +- >>> wrap_method(ZCatalog, 'catalog_object', +- ... catalog_object, pattern=pattern) +- +- >>> wrap_method(ZCatalog, 'uncatalog_object', +- ... uncatalog_object, pattern=pattern) +- +-Disable Portal Factory: +- +- >>> pf = getToolByName(portal, 'portal_factory', None) +- >>> if pf is not None: +- ... pf.manage_setPortalFactoryTypes(listOfTypeIds=[]) +- +-Tests for ATDocument +-------------------- +- +-Simple invokeFactory call, without renaming or fancy extra field +-setting: +- +- >>> _ = folder.invokeFactory(type_name='Document', +- ... id='new_doc1') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc1 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc1 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc1 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc1 [] +- ------------------------------------------------------------ +- +- >>> folder['new_doc1'].Title() +- '' +- +- >>> folder['new_doc1'].Description() +- '' +- +-More complex invokeFactory call, setting title and description: +- +- >>> _ = folder.invokeFactory(type_name='Document', +- ... id='new_doc2', +- ... title='Title', +- ... description='Description') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc2 [] +- ------------------------------------------------------------ +- +- >>> folder['new_doc2'].Title() +- 'Title' +- +- >>> folder['new_doc2'].Description() +- 'Description' +- +-Now hold your breath. We are going to rename, +-copy-and-paste and cut-and-paste. +- +- >>> transaction.savepoint(optimistic=True) and None +- +-Rename: +- +- >>> folder.manage_renameObjects(ids=['new_doc1'], +- ... new_ids=['new_doc11']) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_doc1 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_doc1 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc11 ['getObjPositionInParent'] +- ------------------------------------------------------------ +- +-Copy and paste: +- +- >>> cp = folder.manage_copyObjects(ids=['new_doc2']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc2 ['created'] +- ------------------------------------------------------------ +- +-Cut and paste: +- +- >>> cp = folder.manage_cutObjects(ids=['new_doc11']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_doc11 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_doc11 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_doc11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc11 [] +- ------------------------------------------------------------ +- +-Tests for ATFolder +------------------- +- +-Simple invokeFactory call, without renaming or fancy extra field +-setting: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_folder1') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder1 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder1 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder1 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder1 [] +- ------------------------------------------------------------ +- +- >>> folder['new_folder1'].Title() +- '' +- +- >>> folder['new_folder1'].Description() +- '' +- +-More complex invokeFactory call, setting title and description: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_folder2', +- ... title='Title', +- ... description='Description') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder2 [] +- ------------------------------------------------------------ +- +- >>> folder['new_folder2'].Title() +- 'Title' +- +- >>> folder['new_folder2'].Description() +- 'Description' +- +-Now hold your breath. We are going to rename, +-copy-and-paste and cut-and-paste. +- +- >>> transaction.savepoint(optimistic=True) and None +- +-Rename: +- +- >>> folder.manage_renameObjects(ids=['new_folder1'], +- ... new_ids=['new_folder11']) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_folder1 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_folder1 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder11 ['getObjPositionInParent'] +- ------------------------------------------------------------ +- +-Copy and paste: +- +- >>> cp = folder.manage_copyObjects(ids=['new_folder2']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder2 ['created'] +- ------------------------------------------------------------ +- +-Cut and paste: +- +- >>> cp = folder.manage_cutObjects(ids=['new_folder11']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_folder11 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_folder11 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder11 [] +- ------------------------------------------------------------ +- +-Tests for ATBTreeFolder +------------------------ +- +-Simple invokeFactory call, without renaming or fancy extra field +-setting: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_btree_folder1') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder1 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder1 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder1 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder1 [] +- ------------------------------------------------------------ +- +- >>> folder['new_btree_folder1'].Title() +- '' +- +- >>> folder['new_btree_folder1'].Description() +- '' +- +-More complex invokeFactory call, setting title and description: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_btree_folder2', +- ... title='Title', +- ... description='Description') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder2 [] +- ------------------------------------------------------------ +- +- >>> folder['new_btree_folder2'].Title() +- 'Title' +- +- >>> folder['new_btree_folder2'].Description() +- 'Description' +- +-Now hold your breath. We are going to rename, +-copy-and-paste and cut-and-paste. +- +- >>> transaction.savepoint(optimistic=True) and None +- +-Rename: +- +- >>> folder.manage_renameObjects(ids=['new_btree_folder1'], +- ... new_ids=['new_btree_folder11']) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_btree_folder1 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_btree_folder1 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder11 ['getObjPositionInParent'] +- ------------------------------------------------------------ +- +-Copy and paste: +- +- >>> cp = folder.manage_copyObjects(ids=['new_btree_folder2']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder2 ['created'] +- ------------------------------------------------------------ +- +- +-Cut and paste: +- +- >>> cp = folder.manage_cutObjects(ids=['new_btree_folder11']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_btree_folder11 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_btree_folder11 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_btree_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder11 [] +- ------------------------------------------------------------ +- +-Restore ZCatalog methods: +- +- >>> unwrap_method(ZCatalog, 'catalog_object') +- >>> unwrap_method(ZCatalog, 'uncatalog_object') +diff --git a/Products/ATContentTypes/tests/test_criteria.py b/Products/ATContentTypes/tests/test_criteria.py +index 56f6135..10bb9b6 100644 +--- a/Products/ATContentTypes/tests/test_criteria.py ++++ b/Products/ATContentTypes/tests/test_criteria.py +@@ -21,6 +21,7 @@ + from Products.ATContentTypes.interfaces import IATTopicCriterion + from Products.ATContentTypes.tests import atcttestcase + from zope.interface.verify import verifyObject ++from Products.CMFCore.indexing import processQueue + + import unittest -@@ -38,6 +44,7 @@ def testUpdateTypeIndex(self): - info = self.portal.portal_types.getTypeInfo('File') - info.title = 'Foo' - foo = self.folder[self.folder.invokeFactory('File', id='foo')] +@@ -430,6 +431,7 @@ def test_reference_vocab(self): + self.folder.doc2.setRelatedItems([uid1]) + self.folder.doc1.reindexObject() + self.folder.doc2.reindexObject() + processQueue() - info.title = 'File' - # make sure it's actually wrong... - catalog = self.portal.portal_catalog + vocab = self.dummy.getCurrentValues() + self.assertEqual(len(vocab), 2) + self.assertTrue(uid1 in vocab.keys()) +diff --git a/Products/ATContentTypes/tests/test_doctests.py b/Products/ATContentTypes/tests/test_doctests.py +index 9ef2e61..e666f5a 100644 +--- a/Products/ATContentTypes/tests/test_doctests.py ++++ b/Products/ATContentTypes/tests/test_doctests.py +@@ -12,7 +12,6 @@ + 'portaltype_criterion.txt', + 'webdav.txt', + 'http_access.txt', +- 'reindex_sanity.txt', + 'uploading.txt', + 'browser_collection_views.txt', + # traversal.txt registers the browser page "document_view", and this -Repository: plone.app.blob +Repository: Products.ATContentTypes Branch: refs/heads/master -Date: 2017-02-21T22:15:55+01:00 +Date: 2017-02-21T22:16:29+01:00 Author: Gil Forcada Codinachs (gforcada) -Commit: https://github.com/plone/plone.app.blob/commit/efcbd7bfd69ab4072bd53c368945681492db2ef9 +Commit: https://github.com/plone/Products.ATContentTypes/commit/e39512c1d2b4be4b62dcd7f8287d811e0684093e -Merge pull request #27 from plone/merge-collective-indexing +Merge pull request #34 from plone/merge-collective-indexing Merge collective indexing Files changed: M CHANGES.rst -M src/plone/app/blob/tests/test_maintenance.py +M Products/ATContentTypes/tests/test_criteria.py +M Products/ATContentTypes/tests/test_doctests.py +D Products/ATContentTypes/tests/reindex_sanity.txt diff --git a/CHANGES.rst b/CHANGES.rst -index ba237af..fd4a7a6 100644 +index ae28177..348d84a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -10,7 +10,9 @@ Breaking changes: +@@ -45,6 +45,10 @@ Bug fixes: - New features: + - Require plone.app.imaging even if Plone itself does not. [davisagli] --- *add item here* +- Adapt tests to the new indexing operations queueing. + Part of PLIP 1343: https://github.com/plone/Products.CMFPlone/issues/1343 + [gforcada] - - Bug fixes: - -diff --git a/src/plone/app/blob/tests/test_maintenance.py b/src/plone/app/blob/tests/test_maintenance.py -index a8c502d..6178de0 100644 ---- a/src/plone/app/blob/tests/test_maintenance.py -+++ b/src/plone/app/blob/tests/test_maintenance.py -@@ -4,6 +4,12 @@ - from Products.ATContentTypes.interface import file as atfile - from Products.ATContentTypes.interface import image as atimage - -+try: -+ from Products.CMFCore.indexing import processQueue -+except ImportError: -+ def processQueue(): -+ pass + - class MaintenanceViewTests(ReplacementTestCase): + 2.3 (2016-10-03) + ---------------- +diff --git a/Products/ATContentTypes/tests/reindex_sanity.txt b/Products/ATContentTypes/tests/reindex_sanity.txt +deleted file mode 100644 +index b28205f..0000000 +--- a/Products/ATContentTypes/tests/reindex_sanity.txt ++++ /dev/null +@@ -1,424 +0,0 @@ +-Reindex Sanity +-============== +- +-Those tests make sure that the catalog is only called as necessary. +- +- >>> import sys +- >>> from os.path import sep +- >>> from Products.ZCatalog.ZCatalog import ZCatalog +- >>> from Products.CMFCore.utils import getToolByName +- >>> from Products.Archetypes.utils import wrap_method +- >>> from Products.Archetypes.utils import unwrap_method +- >>> from Products.Archetypes.utils import call_original as call +- >>> from plone.app.testing import TEST_USER_NAME as default_user +- >>> from plone.app.testing import SITE_OWNER_NAME as portal_owner +- >>> import transaction +- +- >>> from plone.app.testing import TEST_USER_ID, setRoles +- >>> portal = layer['portal'] +- >>> setRoles(portal, TEST_USER_ID, ['Manager']) +- >>> folder = portal.portal_membership.getHomeFolder(TEST_USER_ID) +- +- >>> _ = folder.invokeFactory(type_name='Folder', id='sub') +- +- >>> def callers(n=1): +- ... stack = [] +- ... import inspect +- ... frames = inspect.getouterframes(inspect.currentframe()) +- ... fp = filter(None, sys.path) +- ... for i in range(n+1, 1, -1): +- ... try: +- ... frame = frames[i] +- ... except IndexError: +- ... continue +- ... fname, ln, func = frame[1:4] +- ... for p in fp: +- ... fname = fname.split(p)[-1] +- ... fname = fname.split('Products')[-1] +- ... fname = fname.split('.py')[0] +- ... fname = '.'.join(fname.strip(sep).split(sep)) +- ... stack.append(':'.join((fname, str(ln), func))) +- ... return stack +- +-Wrap ZCatalog methods to let us know about why and when they were called: +- +- >>> pattern = '__at_reindex_sanity_%s__' +- +- >>> def catalog_object(self, *args, **kw): +- ... rv = call(self, 'catalog_object', pattern, *args, **kw) +- ... print 'Catalog: ', self.getId() +- ... uid = kw.get('uid', None) +- ... if not uid: +- ... if len(args) > 1: +- ... uid = args[1] +- ... else: +- ... uid = '/'.join(args[0].getPhysicalPath()) +- ... idxs = kw.get('idxs', []) +- ... if not idxs: +- ... if len(args) > 2: +- ... idxs = args[2] +- ... print 'Indexing:', uid, idxs +- ... # The next line is usefull for debugging. +- ... # print 'Callers: ', '\n '.join(callers(15)) +- ... print '-' * 60 +- ... return rv +- +- >>> def uncatalog_object(self, *args, **kw): +- ... rv = call(self, 'uncatalog_object', pattern, *args, **kw) +- ... print 'Catalog: ', self.getId() +- ... print 'UnIndexing:', kw.get('uid', None) or args[0] +- ... # The next line is usefuld for debugging. +- ... # print 'Callers: ', '\n '.join(callers(15)) +- ... print '-' * 60 +- ... return rv +- +- >>> wrap_method(ZCatalog, 'catalog_object', +- ... catalog_object, pattern=pattern) +- +- >>> wrap_method(ZCatalog, 'uncatalog_object', +- ... uncatalog_object, pattern=pattern) +- +-Disable Portal Factory: +- +- >>> pf = getToolByName(portal, 'portal_factory', None) +- >>> if pf is not None: +- ... pf.manage_setPortalFactoryTypes(listOfTypeIds=[]) +- +-Tests for ATDocument +-------------------- +- +-Simple invokeFactory call, without renaming or fancy extra field +-setting: +- +- >>> _ = folder.invokeFactory(type_name='Document', +- ... id='new_doc1') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc1 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc1 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc1 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc1 [] +- ------------------------------------------------------------ +- +- >>> folder['new_doc1'].Title() +- '' +- +- >>> folder['new_doc1'].Description() +- '' +- +-More complex invokeFactory call, setting title and description: +- +- >>> _ = folder.invokeFactory(type_name='Document', +- ... id='new_doc2', +- ... title='Title', +- ... description='Description') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc2 [] +- ------------------------------------------------------------ +- +- >>> folder['new_doc2'].Title() +- 'Title' +- +- >>> folder['new_doc2'].Description() +- 'Description' +- +-Now hold your breath. We are going to rename, +-copy-and-paste and cut-and-paste. +- +- >>> transaction.savepoint(optimistic=True) and None +- +-Rename: +- +- >>> folder.manage_renameObjects(ids=['new_doc1'], +- ... new_ids=['new_doc11']) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_doc1 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_doc1 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_doc11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_doc11 ['getObjPositionInParent'] +- ------------------------------------------------------------ +- +-Copy and paste: +- +- >>> cp = folder.manage_copyObjects(ids=['new_doc2']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc2 ['created'] +- ------------------------------------------------------------ +- +-Cut and paste: +- +- >>> cp = folder.manage_cutObjects(ids=['new_doc11']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_doc11 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_doc11 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_doc11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_doc11 [] +- ------------------------------------------------------------ +- +-Tests for ATFolder +------------------- +- +-Simple invokeFactory call, without renaming or fancy extra field +-setting: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_folder1') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder1 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder1 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder1 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder1 [] +- ------------------------------------------------------------ +- +- >>> folder['new_folder1'].Title() +- '' +- +- >>> folder['new_folder1'].Description() +- '' +- +-More complex invokeFactory call, setting title and description: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_folder2', +- ... title='Title', +- ... description='Description') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder2 [] +- ------------------------------------------------------------ +- +- >>> folder['new_folder2'].Title() +- 'Title' +- +- >>> folder['new_folder2'].Description() +- 'Description' +- +-Now hold your breath. We are going to rename, +-copy-and-paste and cut-and-paste. +- +- >>> transaction.savepoint(optimistic=True) and None +- +-Rename: +- +- >>> folder.manage_renameObjects(ids=['new_folder1'], +- ... new_ids=['new_folder11']) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_folder1 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_folder1 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_folder11 ['getObjPositionInParent'] +- ------------------------------------------------------------ +- +-Copy and paste: +- +- >>> cp = folder.manage_copyObjects(ids=['new_folder2']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder2 ['created'] +- ------------------------------------------------------------ +- +-Cut and paste: +- +- >>> cp = folder.manage_cutObjects(ids=['new_folder11']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_folder11 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_folder11 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_folder11 [] +- ------------------------------------------------------------ +- +-Tests for ATBTreeFolder +------------------------ +- +-Simple invokeFactory call, without renaming or fancy extra field +-setting: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_btree_folder1') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder1 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder1 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder1 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder1 [] +- ------------------------------------------------------------ +- +- >>> folder['new_btree_folder1'].Title() +- '' +- +- >>> folder['new_btree_folder1'].Description() +- '' +- +-More complex invokeFactory call, setting title and description: +- +- >>> _ = folder.invokeFactory(type_name='Folder', +- ... id='new_btree_folder2', +- ... title='Title', +- ... description='Description') +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder2 [] +- ------------------------------------------------------------ +- +- >>> folder['new_btree_folder2'].Title() +- 'Title' +- +- >>> folder['new_btree_folder2'].Description() +- 'Description' +- +-Now hold your breath. We are going to rename, +-copy-and-paste and cut-and-paste. +- +- >>> transaction.savepoint(optimistic=True) and None +- +-Rename: +- +- >>> folder.manage_renameObjects(ids=['new_btree_folder1'], +- ... new_ids=['new_btree_folder11']) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_btree_folder1 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_btree_folder1 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/new_btree_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/new_btree_folder11 ['getObjPositionInParent'] +- ------------------------------------------------------------ +- +-Copy and paste: +- +- >>> cp = folder.manage_copyObjects(ids=['new_btree_folder2']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder2 ['review_state'] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder2 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder2 ['created'] +- ------------------------------------------------------------ +- +- +-Cut and paste: +- +- >>> cp = folder.manage_cutObjects(ids=['new_btree_folder11']) +- >>> _ = folder.sub.manage_pasteObjects(cp) +- Catalog: uid_catalog +- UnIndexing: Members/test_user_1_/new_btree_folder11 +- ------------------------------------------------------------ +- Catalog: portal_catalog +- UnIndexing: /plone/Members/test_user_1_/new_btree_folder11 +- ------------------------------------------------------------ +- Catalog: uid_catalog +- Indexing: Members/test_user_1_/sub/new_btree_folder11 [] +- ------------------------------------------------------------ +- Catalog: portal_catalog +- Indexing: /plone/Members/test_user_1_/sub/new_btree_folder11 [] +- ------------------------------------------------------------ +- +-Restore ZCatalog methods: +- +- >>> unwrap_method(ZCatalog, 'catalog_object') +- >>> unwrap_method(ZCatalog, 'uncatalog_object') +diff --git a/Products/ATContentTypes/tests/test_criteria.py b/Products/ATContentTypes/tests/test_criteria.py +index 56f6135..10bb9b6 100644 +--- a/Products/ATContentTypes/tests/test_criteria.py ++++ b/Products/ATContentTypes/tests/test_criteria.py +@@ -21,6 +21,7 @@ + from Products.ATContentTypes.interfaces import IATTopicCriterion + from Products.ATContentTypes.tests import atcttestcase + from zope.interface.verify import verifyObject ++from Products.CMFCore.indexing import processQueue + + import unittest -@@ -38,6 +44,7 @@ def testUpdateTypeIndex(self): - info = self.portal.portal_types.getTypeInfo('File') - info.title = 'Foo' - foo = self.folder[self.folder.invokeFactory('File', id='foo')] +@@ -430,6 +431,7 @@ def test_reference_vocab(self): + self.folder.doc2.setRelatedItems([uid1]) + self.folder.doc1.reindexObject() + self.folder.doc2.reindexObject() + processQueue() - info.title = 'File' - # make sure it's actually wrong... - catalog = self.portal.portal_catalog + vocab = self.dummy.getCurrentValues() + self.assertEqual(len(vocab), 2) + self.assertTrue(uid1 in vocab.keys()) +diff --git a/Products/ATContentTypes/tests/test_doctests.py b/Products/ATContentTypes/tests/test_doctests.py +index 9ef2e61..e666f5a 100644 +--- a/Products/ATContentTypes/tests/test_doctests.py ++++ b/Products/ATContentTypes/tests/test_doctests.py +@@ -12,7 +12,6 @@ + 'portaltype_criterion.txt', + 'webdav.txt', + 'http_access.txt', +- 'reindex_sanity.txt', + 'uploading.txt', + 'browser_collection_views.txt', + # traversal.txt registers the browser page "document_view", and this