[Zope-Checkins] CVS: Zope2 - testCatalog.py:1.1.4.5

Andreas Jung andreas@dhcp165.digicool.com
Sun, 11 Mar 2001 17:33:50 -0500


Update of /mnt/cvs-repository/Zope2/lib/python/Products/ZCatalog/tests
In directory yetix:/work/Zope2/Catalog-BTrees-Integration/lib/python/Products/ZCatalog/tests

Modified Files:
      Tag: Catalog-BTrees-Integration
	testCatalog.py 
Log Message:
commit



--- Updated File testCatalog.py in package test --
--- testCatalog.py	2001/03/08 12:14:27	1.1.4.4
+++ testCatalog.py	2001/03/11 22:33:40	1.1.4.5
@@ -7,6 +7,18 @@
     Andreas Jung, andreas@digicool.com
     
     $Log$
+    Revision 1.1.4.5  2001/03/11 22:33:40  andreas
+    commit
+
+    Revision 1.1.2.23  2001/03/09 16:06:10  andreas
+    integrated chris unittestCatalog.py
+
+    Revision 1.1.2.22  2001/03/09 15:05:28  andreas
+    rewrote testUpdates()
+
+    Revision 1.1.2.21  2001/03/08 18:42:28  andreas
+    fixed typo
+
     Revision 1.1.4.4  2001/03/08 12:14:27  andreas
     minor changes
 
@@ -44,15 +56,20 @@
 
 import Zope
 import ZODB, ZODB.FileStorage
-from Products.ZCatalog import Catalog,Vocabulary
+from Products.ZCatalog import Catalog,ZCatalog,Vocabulary
 import Persistence
 import ExtensionClass
 from Testing import dispatcher
 import keywords
 from zLOG import LOG
 
+from SearchIndex.UnIndex import UnIndex
+from SearchIndex.UnTextIndex import UnTextIndex
+from SearchIndex.UnKeywordIndex import UnKeywordIndex
+from SearchIndex.Lexicon import Lexicon
+
 import getopt,whrandom,thread,time,string,mailbox,rfc822
-from Testing.unittest import TestCase, TestSuite, TextTestRunner
+from Testing.unittest import TestCase, TestSuite, TextTestRunner,makeSuite
 
 
 # maximum number of files to read for the test suite
@@ -378,7 +395,7 @@
         for i in range(searchIterations):
              for r in results[i]:
                 size = r.length
-                assert rg[i][0]<=size and size<=rg[i][1] , "Filesize of %s is out of range (%d,%d)" % (r.file_id,rg[i][0],rg[i][1])
+                assert rg[i][0]<=size and size<=rg[i][1] , "Filesize of %s is out of range (%d,%d) %d" % (r.file_id,rg[i][0],rg[i][1],size)
         self.th_teardown(env)
 
 
@@ -416,29 +433,39 @@
     #############################################################        
 
     def testUpdates(self,args,kw):
-        """ test reindexing of existing data """
-        self.dispatcher("testUpdates" , ("funcUpdates",4 , () , {} ))
+        """ benchmark concurrent catalog/uncatalog operations """
+        self.dispatcher("testUpdates" , ("funcUpdates", kw["numThreads"] , args, kw ))
 
 
-    def funcUpdates(self,*args):
-        """ benchmark catalog/uncatalog operations """
+    def funcUpdates(self,*args,**kw):
+        """ benchmark concurrent catalog/uncatalog operations """
 
         conflicts = 0
         cat,msg_ids = self.get_catalog()
 
+        msgs = self.setupUpdatesMethod(kw["numUpdates"])
+        keys = msgs.keys()
+
         env = self.th_setup()
+
+        for i in range(len(keys)):
 
-        for i in range(updateIterations):
+            r = whrandom.randint(0,len(msgs)-1)
 
-            r = whrandom.randint(0,len(msg_ids)-1)
+            mid = keys[r]
+            obj = msgs[mid]
 
+
             try:
-                cat.uncatMessage(msg_ids[r])
-                cat.catalogObject("This test sucks",r)
-                if i%10 ==0: get_transaction().commit()            
+                cat.uncatalogObject(mid)
+                cat.catalogObject(obj,mid)
 
+                if kw.get("commit",1)==1:
+                    get_transaction().commit()            
+                    time.sleep(0.1)
+
             except ZODB.POSException.ConflictError:
-                print sys.exc_type,sys.exc_value
+#                print sys.exc_type,sys.exc_value
                 conflicts = conflicts + 1
 
         try:
@@ -450,13 +477,39 @@
         self.th_teardown(env,conflicts=conflicts)
 
 
+    def setupUpdatesMethod(self,numUpdates):
+        """ this method prepares a datastructure for the updates test.
+            we are reading the first n mails from the primary mailbox.
+            they are used for the update test
+        """
+
+        i = 0
+        dict = {}
+
+        mb = mailbox.UnixMailbox(open(mbox,"r"))
+
+        msg = mb.next()
+        while msg and i<numUpdates:
+
+            obj = testMessage(msg)
+            mid = msg.dict["message-id"]
+
+            dict[mid] = obj 
+
+            msg = mb.next()
+            i = i+1
+       
+        return dict 
+    
+
+
     #############################################################        
     # Test full reindexing
     #############################################################        
 
     def testReindexing(self,args,kw):
         """ test reindexing of existing data """
-        self.dispatcher("testReindexing" , ("funcReindexing",1 , (mbox,1000) , {} ))
+        self.dispatcher("testReindexing" , ("funcReindexing",kw["numThreads"] , (mbox,1000) , {} ))
 
 
     def funcReindexing(self,mbox,numfiles=100):
@@ -495,7 +548,7 @@
     
     def testIncrementalIndexing(self,args,kw):
         """ testing incremental indexing """
-        self.dispatcher("testIncrementalIndexing" , ("funcReindexing",1, (mbox2,1000) , {}))
+        self.dispatcher("testIncrementalIndexing" , ("funcReindexing",kw["numThreads"], (mbox2,1000) , {}))
 
 
     def get_catalog(self):
@@ -515,6 +568,193 @@
 
         return cat,msg_ids
 
+################################################################################
+# Stuff of Chris
+################################################################################
+
+
+class CatalogBase:
+    def setUp(self):
+        self._vocabulary = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary',
+                                                 globbing=1)
+        self._catalog = Catalog.Catalog()
+
+    def tearDown(self):
+        self._vocabulary = self._catalog = None
+
+class TestAddDelColumn(CatalogBase, TestCase):
+    def checkAdd(self):
+        self._catalog.addColumn('id')
+        assert self._catalog.schema.has_key('id') == 1, 'add column failed'
+
+    def checkAddBad(self):
+        try:
+            self._catalog.addColumn('_id')
+        except:
+            pass
+        else:
+            raise 'invalid metadata column check failed'
+
+    def checkDel(self):
+        self._catalog.addColumn('id')
+        self._catalog.delColumn('id')
+        assert self._catalog.schema.has_key('id') != 1, 'del column failed'
+
+class TestAddDelIndexes(CatalogBase, TestCase):
+    def checkAddFieldIndex(self):
+        self._catalog.addIndex('id', 'FieldIndex')
+        assert type(self._catalog.indexes['id']) is type(UnIndex('id')),\
+               'add field index failed'
+
+    def checkAddTextIndex(self):
+        self._catalog.addIndex('id', 'TextIndex')
+        i = self._catalog.indexes['id']
+        assert type(i) is type(UnTextIndex('id', None, None, Lexicon())),\
+               'add text index failed'
+
+    def checkAddKeywordIndex(self):
+        self._catalog.addIndex('id', 'KeywordIndex')
+        i = self._catalog.indexes['id']
+        assert type(i) is type(UnKeywordIndex('id')), 'add kw index failed'
+
+    def checkDelFieldIndex(self):
+        self._catalog.addIndex('id', 'FieldIndex')
+        self._catalog.delIndex('id')
+        assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
+        
+    def checkDelTextIndex(self):
+        self._catalog.addIndex('id', 'TextIndex')
+        self._catalog.delIndex('id')
+        assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
+        
+    def checkDelKeywordIndex(self):
+        self._catalog.addIndex('id', 'KeywordIndex')
+        self._catalog.delIndex('id')
+        assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
+
+class TestSimultaneousAddAndRead(CatalogBase, TestCase):
+    def checkMultiThread(self):
+        pass
+
+class TestZCatalogObject(TestCase):
+    def checkInstantiateWithoutVocab(self):
+        v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
+        zc = ZCatalog.ZCatalog('acatalog')
+        assert hasattr(zc, 'Vocabulary')
+        assert zc.getVocabulary().__class__ == v.__class__
+
+    def checkInstantiateWithGlobbingVocab(self):
+        v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
+        zc = ZCatalog.ZCatalog('acatalog', vocab_id='vocab')
+        zc._setObject('vocab', v)
+        assert zc.getVocabulary() == v
+
+    def checkInstantiateWithNormalVocab(self):
+        v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=0)
+        zc = ZCatalog.ZCatalog('acatalog', vocab_id='vocab')
+        zc._setObject('vocab', v)
+        assert zc.getVocabulary() == v
+
+class TestCatalogObject(TestCase):
+    def setUp(self):
+        self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary',
+                                                 globbing=1)
+        self._catalog = Catalog.Catalog()
+        self._catalog.addIndex('col1', 'FieldIndex')
+        self._catalog.addIndex('col2', 'TextIndex')
+        self._catalog.addIndex('col3', 'KeywordIndex')
+        self._catalog.addColumn('col1') 
+        self._catalog.addColumn('col2')
+        self._catalog.addColumn('col3')
+        
+        self._catalog.addIndex('att1', 'FieldIndex')
+        self._catalog.addIndex('att2', 'TextIndex')
+        self._catalog.addIndex('att3', 'KeywordIndex')
+        self._catalog.addColumn('att1') 
+        self._catalog.addColumn('att2')
+        self._catalog.addColumn('att3')
+
+        self._catalog.addColumn('num')
+        self.upper = 1000
+        class dummy(ExtensionClass.Base):
+            att1 = 'att1'
+            att2 = 'att2'
+            att3 = ['att3']
+            def __init__(self, num):
+                self.num = num
+                
+            def col1(self):
+                return 'col1'
+
+            def col2(self):
+                return 'col2'
+
+            def col3(self):
+                return ['col3']
+        for x in range(0, self.upper):
+            self._catalog.catalogObject(dummy(x), `x`)
+        self._catalog.aq_parent = dummy('foo') # fake out acquisition
+
+    def tearDown(self):
+        self._vocabulary = self._catalog = None
+
+    def checkResultLength(self):
+        upper = self.upper
+        a = self._catalog()
+        assert len(a) == upper, 'length should be %s, its %s'%(upper, len(a))
+
+    def checkFieldIndexLength(self):
+        a = self._catalog(att1='att1')
+        assert len(a) == self.upper, 'should be %s, but is %s' % (self.upper,
+                                                                  len(a))
+    def checkTextIndexLength(self):
+        a = self._catalog(att2='att2')
+        assert len(a) == self.upper, 'should be %s, but is %s' % (self.upper,
+                                                                  len(a))
+
+    def checkKeywordIndexLength(self):
+        a = self._catalog(att3='att3')
+        assert len(a) == self.upper, 'should be %s, but is %s' % (self.upper,
+                                                                  len(a))
+
+    def checkUncatalogFieldIndex(self):    
+        self.uncatalog()
+        a = self._catalog(att1='att1')
+        assert len(a) == 0, 'len: %s' % (len(a))
+        
+    def checkUncatalogTextIndex(self):
+        self.uncatalog()
+        a = self._catalog(att2='att2')
+        assert len(a) == 0, 'len: %s' % (len(a))
+
+    def checkUncatalogKeywordIndex(self):
+        self.uncatalog()
+        a = self._catalog(att3='att3')
+        assert len(a) == 0, 'len: %s'%(len(a))
+
+    def checkBadUncatalog(self):
+        try:
+            self._catalog.uncatalogObject('asdasdasd')
+        except:
+            assert 1==2, 'uncatalogObject raised exception on bad uid'
+
+    def checkUniqueValuesForLength(self):
+        a = self._catalog.uniqueValuesFor('att1')
+        assert len(a) == 1, 'bad number of unique values %s' % str(a)
+
+    def checkUniqueValuesForContent(self):
+        a = self._catalog.uniqueValuesFor('att1')
+        assert a[0] == 'att1', 'bad content %s' % str(a[0])
+
+    def uncatalog(self):
+        for x in range(0, self.upper):
+            self._catalog.uncatalogObject(`x`)
+
+# environment
+
+
+
+
     
 
 
@@ -522,9 +762,9 @@
 def usage(program):
     print "Usage: "
     print
-    print "initalize the test catalog:   %s -i -f <maximum number files to use> [-d <data directory>] " % program
-    print "to run the basic tests:       %s -b -f <maximum number files to use> [-n <number of threads>]" % program
-    print "to run the advanced tests:    %s -a -f <maximum number files to use> [-n <number of threads>]" % program
+    print "initalize the test catalog:   %s -i -f <maximum number files to use> " % program
+    print "to run the basic tests:       %s -b -f <maximum number files to use> " % program
+    print "to run the advanced tests:    %s -a -f <maximum number files to use> " % program
 
                 
 if __name__ == '__main__':
@@ -533,7 +773,7 @@
 
     mainThreadID = thread.get_ident()
 
-    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:",['help'])
+    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:x",['help'])
     opts.sort()
 
     optsLst = map(lambda x: x[0],opts)
@@ -562,12 +802,25 @@
             
     if '-b' in optsLst:
 
+        # Chris' tests
+        s1 = makeSuite(TestAddDelIndexes, 'check')
+        s2 = makeSuite(TestCatalogObject, 'check')
+        s3 = makeSuite(TestAddDelColumn, 'check')
+        s4 = makeSuite(TestZCatalogObject, 'check')
+    
+        testsuite = TestSuite((s1,s2,s3,s4,))
+
+        runner = TextTestRunner()
+        runner.run(testsuite)
+
+        # andreas' tests
+
         basic_tests = [
              testSearches("testFulltextIndex",numThreads=1),
              testSearches("testFulltextIndex",numThreads= 4),
              testSearches("testFieldIndex",numThreads= 1),
              testSearches("testFieldIndex",numThreads= 4),
-             testSearches("testFieldRangeIndex",numThread= 1),
+             testSearches("testFieldRangeIndex",numThreads=1),
              testSearches("testFieldRangeIndex",numThreads= 4),
              testSearches("testKeywordIndex",numThreads= 1),
              testSearches("testKeywordIndex",numThreads= 4),
@@ -584,9 +837,10 @@
     if '-a' in optsLst:
 
         basic_tests = [
-            testSearches("testUpdates",(),{"numThreads" : 4}),
-            testSearches("testReindexing",(),{"numThreads" : 1}),
-            testSearches("testIncrementalIndexing",(),{"numThreads" : 1})
+           testSearches("testReindexing",numThreads=1),
+           testSearches("testIncrementalIndexing",numThreads=1),
+           testSearches("testUpdates",numThreads=2,numUpdates=200),
+           testSearches("testUpdates",numThreads=4,numUpdates=200)
         ]
             
         testsuite1 = TestSuite()
@@ -594,3 +848,19 @@
 
         runner = TextTestRunner()
         runner.run(testsuite1)
+
+    if '-x' in optsLst:
+
+        basic_tests = [
+            testSearches("testUpdates",numThreads=1,numUpdates=100),
+            testSearches("testUpdates",numThreads=1,numUpdates=100,commit=0),
+            testSearches("testUpdates",numThreads=2,numUpdates=100),
+            testSearches("testUpdates",numThreads=2,numUpdates=100,commit=0),
+        ]
+
+        testsuite1 = TestSuite()
+        for x in basic_tests: testsuite1.addTest(x)
+
+        runner = TextTestRunner()
+        runner.run(testsuite1)
+



--- Updated File testCatalog.py in package Zope2 --
--- testCatalog.py	2001/03/08 12:14:27	1.1.4.4
+++ testCatalog.py	2001/03/11 22:33:40	1.1.4.5
@@ -7,6 +7,18 @@
     Andreas Jung, andreas@digicool.com
     
     $Log$
+    Revision 1.1.4.5  2001/03/11 22:33:40  andreas
+    commit
+
+    Revision 1.1.2.23  2001/03/09 16:06:10  andreas
+    integrated chris unittestCatalog.py
+
+    Revision 1.1.2.22  2001/03/09 15:05:28  andreas
+    rewrote testUpdates()
+
+    Revision 1.1.2.21  2001/03/08 18:42:28  andreas
+    fixed typo
+
     Revision 1.1.4.4  2001/03/08 12:14:27  andreas
     minor changes
 
@@ -44,15 +56,20 @@
 
 import Zope
 import ZODB, ZODB.FileStorage
-from Products.ZCatalog import Catalog,Vocabulary
+from Products.ZCatalog import Catalog,ZCatalog,Vocabulary
 import Persistence
 import ExtensionClass
 from Testing import dispatcher
 import keywords
 from zLOG import LOG
 
+from SearchIndex.UnIndex import UnIndex
+from SearchIndex.UnTextIndex import UnTextIndex
+from SearchIndex.UnKeywordIndex import UnKeywordIndex
+from SearchIndex.Lexicon import Lexicon
+
 import getopt,whrandom,thread,time,string,mailbox,rfc822
-from Testing.unittest import TestCase, TestSuite, TextTestRunner
+from Testing.unittest import TestCase, TestSuite, TextTestRunner,makeSuite
 
 
 # maximum number of files to read for the test suite
@@ -378,7 +395,7 @@
         for i in range(searchIterations):
              for r in results[i]:
                 size = r.length
-                assert rg[i][0]<=size and size<=rg[i][1] , "Filesize of %s is out of range (%d,%d)" % (r.file_id,rg[i][0],rg[i][1])
+                assert rg[i][0]<=size and size<=rg[i][1] , "Filesize of %s is out of range (%d,%d) %d" % (r.file_id,rg[i][0],rg[i][1],size)
         self.th_teardown(env)
 
 
@@ -416,29 +433,39 @@
     #############################################################        
 
     def testUpdates(self,args,kw):
-        """ test reindexing of existing data """
-        self.dispatcher("testUpdates" , ("funcUpdates",4 , () , {} ))
+        """ benchmark concurrent catalog/uncatalog operations """
+        self.dispatcher("testUpdates" , ("funcUpdates", kw["numThreads"] , args, kw ))
 
 
-    def funcUpdates(self,*args):
-        """ benchmark catalog/uncatalog operations """
+    def funcUpdates(self,*args,**kw):
+        """ benchmark concurrent catalog/uncatalog operations """
 
         conflicts = 0
         cat,msg_ids = self.get_catalog()
 
+        msgs = self.setupUpdatesMethod(kw["numUpdates"])
+        keys = msgs.keys()
+
         env = self.th_setup()
+
+        for i in range(len(keys)):
 
-        for i in range(updateIterations):
+            r = whrandom.randint(0,len(msgs)-1)
 
-            r = whrandom.randint(0,len(msg_ids)-1)
+            mid = keys[r]
+            obj = msgs[mid]
 
+
             try:
-                cat.uncatMessage(msg_ids[r])
-                cat.catalogObject("This test sucks",r)
-                if i%10 ==0: get_transaction().commit()            
+                cat.uncatalogObject(mid)
+                cat.catalogObject(obj,mid)
 
+                if kw.get("commit",1)==1:
+                    get_transaction().commit()            
+                    time.sleep(0.1)
+
             except ZODB.POSException.ConflictError:
-                print sys.exc_type,sys.exc_value
+#                print sys.exc_type,sys.exc_value
                 conflicts = conflicts + 1
 
         try:
@@ -450,13 +477,39 @@
         self.th_teardown(env,conflicts=conflicts)
 
 
+    def setupUpdatesMethod(self,numUpdates):
+        """ this method prepares a datastructure for the updates test.
+            we are reading the first n mails from the primary mailbox.
+            they are used for the update test
+        """
+
+        i = 0
+        dict = {}
+
+        mb = mailbox.UnixMailbox(open(mbox,"r"))
+
+        msg = mb.next()
+        while msg and i<numUpdates:
+
+            obj = testMessage(msg)
+            mid = msg.dict["message-id"]
+
+            dict[mid] = obj 
+
+            msg = mb.next()
+            i = i+1
+       
+        return dict 
+    
+
+
     #############################################################        
     # Test full reindexing
     #############################################################        
 
     def testReindexing(self,args,kw):
         """ test reindexing of existing data """
-        self.dispatcher("testReindexing" , ("funcReindexing",1 , (mbox,1000) , {} ))
+        self.dispatcher("testReindexing" , ("funcReindexing",kw["numThreads"] , (mbox,1000) , {} ))
 
 
     def funcReindexing(self,mbox,numfiles=100):
@@ -495,7 +548,7 @@
     
     def testIncrementalIndexing(self,args,kw):
         """ testing incremental indexing """
-        self.dispatcher("testIncrementalIndexing" , ("funcReindexing",1, (mbox2,1000) , {}))
+        self.dispatcher("testIncrementalIndexing" , ("funcReindexing",kw["numThreads"], (mbox2,1000) , {}))
 
 
     def get_catalog(self):
@@ -515,6 +568,193 @@
 
         return cat,msg_ids
 
+################################################################################
+# Stuff of Chris
+################################################################################
+
+
+class CatalogBase:
+    def setUp(self):
+        self._vocabulary = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary',
+                                                 globbing=1)
+        self._catalog = Catalog.Catalog()
+
+    def tearDown(self):
+        self._vocabulary = self._catalog = None
+
+class TestAddDelColumn(CatalogBase, TestCase):
+    def checkAdd(self):
+        self._catalog.addColumn('id')
+        assert self._catalog.schema.has_key('id') == 1, 'add column failed'
+
+    def checkAddBad(self):
+        try:
+            self._catalog.addColumn('_id')
+        except:
+            pass
+        else:
+            raise 'invalid metadata column check failed'
+
+    def checkDel(self):
+        self._catalog.addColumn('id')
+        self._catalog.delColumn('id')
+        assert self._catalog.schema.has_key('id') != 1, 'del column failed'
+
+class TestAddDelIndexes(CatalogBase, TestCase):
+    def checkAddFieldIndex(self):
+        self._catalog.addIndex('id', 'FieldIndex')
+        assert type(self._catalog.indexes['id']) is type(UnIndex('id')),\
+               'add field index failed'
+
+    def checkAddTextIndex(self):
+        self._catalog.addIndex('id', 'TextIndex')
+        i = self._catalog.indexes['id']
+        assert type(i) is type(UnTextIndex('id', None, None, Lexicon())),\
+               'add text index failed'
+
+    def checkAddKeywordIndex(self):
+        self._catalog.addIndex('id', 'KeywordIndex')
+        i = self._catalog.indexes['id']
+        assert type(i) is type(UnKeywordIndex('id')), 'add kw index failed'
+
+    def checkDelFieldIndex(self):
+        self._catalog.addIndex('id', 'FieldIndex')
+        self._catalog.delIndex('id')
+        assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
+        
+    def checkDelTextIndex(self):
+        self._catalog.addIndex('id', 'TextIndex')
+        self._catalog.delIndex('id')
+        assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
+        
+    def checkDelKeywordIndex(self):
+        self._catalog.addIndex('id', 'KeywordIndex')
+        self._catalog.delIndex('id')
+        assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
+
+class TestSimultaneousAddAndRead(CatalogBase, TestCase):
+    def checkMultiThread(self):
+        pass
+
+class TestZCatalogObject(TestCase):
+    def checkInstantiateWithoutVocab(self):
+        v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
+        zc = ZCatalog.ZCatalog('acatalog')
+        assert hasattr(zc, 'Vocabulary')
+        assert zc.getVocabulary().__class__ == v.__class__
+
+    def checkInstantiateWithGlobbingVocab(self):
+        v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
+        zc = ZCatalog.ZCatalog('acatalog', vocab_id='vocab')
+        zc._setObject('vocab', v)
+        assert zc.getVocabulary() == v
+
+    def checkInstantiateWithNormalVocab(self):
+        v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=0)
+        zc = ZCatalog.ZCatalog('acatalog', vocab_id='vocab')
+        zc._setObject('vocab', v)
+        assert zc.getVocabulary() == v
+
+class TestCatalogObject(TestCase):
+    def setUp(self):
+        self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary',
+                                                 globbing=1)
+        self._catalog = Catalog.Catalog()
+        self._catalog.addIndex('col1', 'FieldIndex')
+        self._catalog.addIndex('col2', 'TextIndex')
+        self._catalog.addIndex('col3', 'KeywordIndex')
+        self._catalog.addColumn('col1') 
+        self._catalog.addColumn('col2')
+        self._catalog.addColumn('col3')
+        
+        self._catalog.addIndex('att1', 'FieldIndex')
+        self._catalog.addIndex('att2', 'TextIndex')
+        self._catalog.addIndex('att3', 'KeywordIndex')
+        self._catalog.addColumn('att1') 
+        self._catalog.addColumn('att2')
+        self._catalog.addColumn('att3')
+
+        self._catalog.addColumn('num')
+        self.upper = 1000
+        class dummy(ExtensionClass.Base):
+            att1 = 'att1'
+            att2 = 'att2'
+            att3 = ['att3']
+            def __init__(self, num):
+                self.num = num
+                
+            def col1(self):
+                return 'col1'
+
+            def col2(self):
+                return 'col2'
+
+            def col3(self):
+                return ['col3']
+        for x in range(0, self.upper):
+            self._catalog.catalogObject(dummy(x), `x`)
+        self._catalog.aq_parent = dummy('foo') # fake out acquisition
+
+    def tearDown(self):
+        self._vocabulary = self._catalog = None
+
+    def checkResultLength(self):
+        upper = self.upper
+        a = self._catalog()
+        assert len(a) == upper, 'length should be %s, its %s'%(upper, len(a))
+
+    def checkFieldIndexLength(self):
+        a = self._catalog(att1='att1')
+        assert len(a) == self.upper, 'should be %s, but is %s' % (self.upper,
+                                                                  len(a))
+    def checkTextIndexLength(self):
+        a = self._catalog(att2='att2')
+        assert len(a) == self.upper, 'should be %s, but is %s' % (self.upper,
+                                                                  len(a))
+
+    def checkKeywordIndexLength(self):
+        a = self._catalog(att3='att3')
+        assert len(a) == self.upper, 'should be %s, but is %s' % (self.upper,
+                                                                  len(a))
+
+    def checkUncatalogFieldIndex(self):    
+        self.uncatalog()
+        a = self._catalog(att1='att1')
+        assert len(a) == 0, 'len: %s' % (len(a))
+        
+    def checkUncatalogTextIndex(self):
+        self.uncatalog()
+        a = self._catalog(att2='att2')
+        assert len(a) == 0, 'len: %s' % (len(a))
+
+    def checkUncatalogKeywordIndex(self):
+        self.uncatalog()
+        a = self._catalog(att3='att3')
+        assert len(a) == 0, 'len: %s'%(len(a))
+
+    def checkBadUncatalog(self):
+        try:
+            self._catalog.uncatalogObject('asdasdasd')
+        except:
+            assert 1==2, 'uncatalogObject raised exception on bad uid'
+
+    def checkUniqueValuesForLength(self):
+        a = self._catalog.uniqueValuesFor('att1')
+        assert len(a) == 1, 'bad number of unique values %s' % str(a)
+
+    def checkUniqueValuesForContent(self):
+        a = self._catalog.uniqueValuesFor('att1')
+        assert a[0] == 'att1', 'bad content %s' % str(a[0])
+
+    def uncatalog(self):
+        for x in range(0, self.upper):
+            self._catalog.uncatalogObject(`x`)
+
+# environment
+
+
+
+
     
 
 
@@ -522,9 +762,9 @@
 def usage(program):
     print "Usage: "
     print
-    print "initalize the test catalog:   %s -i -f <maximum number files to use> [-d <data directory>] " % program
-    print "to run the basic tests:       %s -b -f <maximum number files to use> [-n <number of threads>]" % program
-    print "to run the advanced tests:    %s -a -f <maximum number files to use> [-n <number of threads>]" % program
+    print "initalize the test catalog:   %s -i -f <maximum number files to use> " % program
+    print "to run the basic tests:       %s -b -f <maximum number files to use> " % program
+    print "to run the advanced tests:    %s -a -f <maximum number files to use> " % program
 
                 
 if __name__ == '__main__':
@@ -533,7 +773,7 @@
 
     mainThreadID = thread.get_ident()
 
-    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:",['help'])
+    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:x",['help'])
     opts.sort()
 
     optsLst = map(lambda x: x[0],opts)
@@ -562,12 +802,25 @@
             
     if '-b' in optsLst:
 
+        # Chris' tests
+        s1 = makeSuite(TestAddDelIndexes, 'check')
+        s2 = makeSuite(TestCatalogObject, 'check')
+        s3 = makeSuite(TestAddDelColumn, 'check')
+        s4 = makeSuite(TestZCatalogObject, 'check')
+    
+        testsuite = TestSuite((s1,s2,s3,s4,))
+
+        runner = TextTestRunner()
+        runner.run(testsuite)
+
+        # andreas' tests
+
         basic_tests = [
              testSearches("testFulltextIndex",numThreads=1),
              testSearches("testFulltextIndex",numThreads= 4),
              testSearches("testFieldIndex",numThreads= 1),
              testSearches("testFieldIndex",numThreads= 4),
-             testSearches("testFieldRangeIndex",numThread= 1),
+             testSearches("testFieldRangeIndex",numThreads=1),
              testSearches("testFieldRangeIndex",numThreads= 4),
              testSearches("testKeywordIndex",numThreads= 1),
              testSearches("testKeywordIndex",numThreads= 4),
@@ -584,9 +837,10 @@
     if '-a' in optsLst:
 
         basic_tests = [
-            testSearches("testUpdates",(),{"numThreads" : 4}),
-            testSearches("testReindexing",(),{"numThreads" : 1}),
-            testSearches("testIncrementalIndexing",(),{"numThreads" : 1})
+           testSearches("testReindexing",numThreads=1),
+           testSearches("testIncrementalIndexing",numThreads=1),
+           testSearches("testUpdates",numThreads=2,numUpdates=200),
+           testSearches("testUpdates",numThreads=4,numUpdates=200)
         ]
             
         testsuite1 = TestSuite()
@@ -594,3 +848,19 @@
 
         runner = TextTestRunner()
         runner.run(testsuite1)
+
+    if '-x' in optsLst:
+
+        basic_tests = [
+            testSearches("testUpdates",numThreads=1,numUpdates=100),
+            testSearches("testUpdates",numThreads=1,numUpdates=100,commit=0),
+            testSearches("testUpdates",numThreads=2,numUpdates=100),
+            testSearches("testUpdates",numThreads=2,numUpdates=100,commit=0),
+        ]
+
+        testsuite1 = TestSuite()
+        for x in basic_tests: testsuite1.addTest(x)
+
+        runner = TextTestRunner()
+        runner.run(testsuite1)
+