[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog/tests - testCatalog.py:1.17.4.1

Chris McDonough chrism@zope.com
Thu, 29 Aug 2002 01:31:53 -0400


Update of /cvs-repository/Zope/lib/python/Products/ZCatalog/tests
In directory cvs.zope.org:/tmp/cvs-serv30531/lib/python/Products/ZCatalog/tests

Modified Files:
      Tag: chrism-install-branch
	testCatalog.py 
Log Message:
CVS up -j from HEAD on chrism-installer-branch.

Sorry folks on various mailing lists whom are subjected to this.
If I knew how to cut down on unnecessary checkin messages to
the lists, I would.



=== Zope/lib/python/Products/ZCatalog/tests/testCatalog.py 1.17 => 1.17.4.1 ===
--- 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	Thu Aug 29 01:31:21 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')
+