[Checkins] SVN: Products.ZCatalog/trunk/s Avoid full-stack test setup
Hanno Schlichting
hannosch at hannosch.eu
Sat Dec 25 13:29:55 EST 2010
Log message for revision 119095:
Avoid full-stack test setup
Changed:
U Products.ZCatalog/trunk/setup.py
U Products.ZCatalog/trunk/src/Products/PluginIndexes/FieldIndex/tests/testFieldIndex.py
U Products.ZCatalog/trunk/src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
U Products.ZCatalog/trunk/src/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py
U Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py
U Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py
U Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py
-=-
Modified: Products.ZCatalog/trunk/setup.py
===================================================================
--- Products.ZCatalog/trunk/setup.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/setup.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -38,7 +38,6 @@
'Products.ZCTextIndex',
'Record',
'RestrictedPython',
- 'transaction',
'zExceptions',
'ZODB3',
'Zope2',
Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/FieldIndex/tests/testFieldIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/FieldIndex/tests/testFieldIndex.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/FieldIndex/tests/testFieldIndex.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -14,8 +14,6 @@
"""
import unittest
-import Zope2
-Zope2.startup()
from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -14,8 +14,6 @@
"""
import unittest
-import Zope2
-Zope2.startup()
from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex
Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -14,8 +14,6 @@
"""
import unittest
-import Zope2
-Zope2.startup()
from Products.PluginIndexes.TopicIndex.TopicIndex import TopicIndex
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -831,9 +831,12 @@
# Indexing methods
def addIndex(self, name, type, extra=None):
+ if IPluggableIndex.providedBy(type):
+ self._catalog.addIndex(name, type)
+ return
+
# Convert the type by finding an appropriate product which supports
# this interface by that name. Bleah
-
products = ObjectManager.all_meta_types(self,
interfaces=(IPluggableIndex, ))
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -15,37 +15,18 @@
import unittest
from Testing.ZopeTestCase.warnhook import WarningsHook
-import Zope2
-Zope2.startup()
from itertools import chain
import random
import ExtensionClass
-import OFS.Application
from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex
from Products.ZCTextIndex.OkapiIndex import OkapiIndex
from Products.ZCTextIndex.ZCTextIndex import PLexicon
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
-from ZODB.DB import DB
-from ZODB.DemoStorage import DemoStorage
-import transaction
-def createDatabase():
- # Create a DemoStorage and put an Application in it
- db = DB(DemoStorage())
- conn = db.open()
- root = conn.root()
- app = OFS.Application.Application()
- root['Application'] = app
- transaction.commit()
- return app
-
-app = createDatabase()
-
-
def sort(iterable, reverse=False):
L = list(iterable)
if reverse:
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py 2010-12-25 18:08:58 UTC (rev 119094)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py 2010-12-25 18:29:55 UTC (rev 119095)
@@ -14,34 +14,15 @@
"""
import unittest
-import Zope2
-Zope2.startup()
from AccessControl.SecurityManagement import setSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl import Unauthorized
from Acquisition import Implicit
import ExtensionClass
-import OFS.Application
from OFS.Folder import Folder as OFS_Folder
-from ZODB.DB import DB
-from ZODB.DemoStorage import DemoStorage
-import transaction
-def createDatabase():
- # Create a DemoStorage and put an Application in it
- db = DB(DemoStorage())
- conn = db.open()
- root = conn.root()
- app = OFS.Application.Application()
- root['Application'] = app
- transaction.commit()
- return app
-
-app = createDatabase()
-
-
class Folder(OFS_Folder):
def __init__(self, id):
self._setId(id)
@@ -122,6 +103,10 @@
from Products.ZCatalog.ZCatalog import ZCatalog
return ZCatalog('Catalog')
+ def _makeOneIndex(self, name):
+ from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
+ return FieldIndex(name)
+
def setUp(self):
self._catalog = self._makeOne()
@@ -133,8 +118,12 @@
def setUp(self):
ZCatalogBase.setUp(self)
+
self._catalog.resolve_path = self._resolve_num
- self._catalog.addIndex('title', 'KeywordIndex')
+ from Products.PluginIndexes.KeywordIndex.KeywordIndex import \
+ KeywordIndex
+ title = KeywordIndex('title')
+ self._catalog.addIndex('title', title)
self._catalog.addColumn('title')
self.upper = 10
@@ -303,17 +292,17 @@
class TestAddDelColumnIndex(ZCatalogBase, unittest.TestCase):
def testAddIndex(self):
- self._catalog.addIndex('id', 'FieldIndex')
+ self._catalog.addIndex('id', self._makeOneIndex('id'))
self.assert_('id' in self._catalog.indexes())
def testDelIndex(self):
- self._catalog.addIndex('title', 'FieldIndex')
+ self._catalog.addIndex('title', self._makeOneIndex('title'))
self.assert_('title' in self._catalog.indexes())
self._catalog.delIndex('title')
self.assert_('title' not in self._catalog.indexes())
def testClearIndex(self):
- self._catalog.addIndex('title', 'FieldIndex')
+ self._catalog.addIndex('title', self._makeOneIndex('title'))
idx = self._catalog._catalog.getIndex('title')
for x in range(10):
ob = zdummy(x)
@@ -337,7 +326,7 @@
def setUp(self):
ZCatalogBase.setUp(self)
- self._catalog.addIndex('id', 'FieldIndex')
+ self._catalog.addIndex('id', self._makeOneIndex('id'))
root = Folder('')
root.getPhysicalRoot = lambda: root
self.root = root
More information about the checkins
mailing list