[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog/tests - testCatalog.py:1.18
Andy
andy@agmweb.ca
Wed, 28 Aug 2002 13:08:50 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog/tests
In directory cvs.zope.org:/tmp/cvs-serv4502
Modified Files:
testCatalog.py
Log Message:
Add in tests for ZCatalog (as opposed to Catalog) for getMetadataForUID and getIndexForUID...
=== Zope/lib/python/Products/ZCatalog/tests/testCatalog.py 1.17 => 1.18 ===
--- Zope/lib/python/Products/ZCatalog/tests/testCatalog.py:1.17 Wed Aug 14 18:25:17 2002
+++ Zope/lib/python/Products/ZCatalog/tests/testCatalog.py Wed Aug 28 13:08:50 2002
@@ -7,6 +7,7 @@
import ZODB, OFS.Application
from ZODB.DemoStorage import DemoStorage
from ZODB.DB import DB
+from Products import ZCatalog
from Products.ZCatalog import ZCatalog,Vocabulary
from Products.ZCatalog.Catalog import Catalog, CatalogError
import ExtensionClass
@@ -125,6 +126,38 @@
# Removed unittests dealing with catalog instantiation and vocabularies
# since catalog no longer creates/manages vocabularies automatically (Casey)
+# Test of the ZCatalog object, as opposed to Catalog
+
+class TestZCatalog(unittest.TestCase):
+ def setUp(self):
+ self._catalog = ZCatalog.ZCatalog('Catalog')
+ self._catalog.addIndex('title', 'KeywordIndex')
+ self._catalog.addColumn('title')
+
+ self.upper = 10
+
+ class dummy(ExtensionClass.Base):
+ def __init__(self, num):
+ self.num = num
+
+ def title(self):
+ return '%d' % self.num
+
+ for x in range(0, self.upper):
+ # make uid a string of the number
+ self._catalog.catalog_object(dummy(x), str(x))
+
+
+ def testGetMetadataForUID(self):
+ testNum = str(self.upper - 3) # as good as any..
+ data = self._catalog.getMetadataForUID(testNum)
+ assert data['title'] == testNum
+
+ def testGetIndexDataForUID(self):
+ testNum = str(self.upper - 3)
+ data = self._catalog.getIndexDataForUID(testNum)
+ assert data['title'][0] == testNum
+
class TestCatalogObject(unittest.TestCase):
def setUp(self):
self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary',
@@ -314,7 +347,6 @@
a = self._catalog(sort_on='att1')
self.assertEqual(len(a), self.upper)
-
class objRS(ExtensionClass.Base):
def __init__(self,num):
@@ -354,9 +386,11 @@
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestAddDelColumn ) )
suite.addTest( unittest.makeSuite( TestAddDelIndexes ) )
+ suite.addTest( unittest.makeSuite( TestZCatalog ) )
suite.addTest( unittest.makeSuite( TestCatalogObject ) )
suite.addTest( unittest.makeSuite( testRS ) )
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
+