[Zope-CVS] CVS: Products/ZCTextIndex/tests - indexhtml.py:1.4 mailtest.py:1.3 testZCTextIndex.py:1.6

Jeremy Hylton jeremy@zope.com
Wed, 15 May 2002 19:47:31 -0400


Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv11366/tests

Modified Files:
	indexhtml.py mailtest.py testZCTextIndex.py 
Log Message:
Change query() method of ZCTextIndex to return nbest, num.

Otherwise, there's no way to report the total number of matches from
which the nbest were selected.  

I changed all the functional tests that I knew how to fix, but not the
mhindex stuff.  All unit tests pass.



=== Products/ZCTextIndex/tests/indexhtml.py 1.3 => 1.4 ===
 
 import os
+from time import clock
 
 import ZODB
 from ZODB.FileStorage import FileStorage
@@ -29,15 +30,19 @@
     extra.lexicon_id = "lexicon"
     caller = Struct()
     caller.lexicon = Lexicon(HTMLWordSplitter(), StopWordRemover())
-    return ZCTextIndex(extra, caller)
+    return ZCTextIndex("read", extra, caller)
 
 def main(db, root, dir):
     rt["index"] = index = make_index()
     rt["files"] = paths = IOBTree()
     get_transaction().commit()
 
+    zodb_time = 0.0
+    pack_time = 0.0
+
     files = [os.path.join(dir, file) for file in os.listdir(dir)]
     docid = 0
+    t0 = clock()
     for file in files:
         if os.path.isdir(file):
             files += [os.path.join(file, sub) for sub in os.listdir(file)]
@@ -51,10 +56,25 @@
             index.index_object(docid, f)
             f.close()
             if docid % TXN_INTERVAL == 0:
+                z0 = clock()
                 get_transaction().commit()
+                z1 = clock()
+                zodb_time += z1 - z0
             if docid % PACK_INTERVAL == 0:
+                p0 = clock()
                 db.pack()
+                p1 = clock()
+                zodb_time += p1 - p0
+                zodb_time += p1 - p0
+    z0 = clock()
     get_transaction().commit()
+    z1 = t1 = clock()
+    total_time = t1 - t0
+    zodb_time += z1 - z0
+    if VERBOSE:
+        print "Total index time", total_time
+        print "Non-pack time", total_time - pack_time
+        print "Non-ZODB time", total_time - zodb_time
 
 if __name__ == "__main__":
     import sys


=== Products/ZCTextIndex/tests/mailtest.py 1.2 => 1.3 ===
     idx = rt["index"]
     docs = rt["documents"]
-    results = idx.query(query_str, BEST)
+    results, num_results = idx.query(query_str, BEST)
     print "query:", query_str
     print "# results:", len(results)
     for docid, score in results:


=== Products/ZCTextIndex/tests/testZCTextIndex.py 1.5 => 1.6 ===
             wq = self.index.query_weight(q.terms())
             eq(wq, scaled_int(wqs[i]))
-            r = self.zc_index.query(raw)
+            r, n = self.zc_index.query(raw)
             self.assertEqual(len(r), len(results[i]))
             # convert the results to a dict for each checking
             d = {}