[Zope-Checkins] CVS: Packages/SearchIndex/tests - testUnTextIndex.py:1.6
Evan Simpson
evan@digicool.com
Mon, 30 Jul 2001 18:09:52 -0400
Update of /cvs-repository/Packages/SearchIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv20538/SearchIndex/tests
Modified Files:
testUnTextIndex.py
Log Message:
Merge TextIndex fixes from 2.4 branch
=== Packages/SearchIndex/tests/testUnTextIndex.py 1.5 => 1.6 ===
"""I hope I get to work on time""",
]
-
- def checkGlobQuery(self):
+
+ def globTest(self, qmap, rlist):
"Check a glob query"
index=self.dbopen()
index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
@@ -232,162 +232,61 @@
index=self.dbopen()
- r = index._apply_index({'text':'m*n'})
- r=list(r[0].keys())
- assert r == [0,2], r
+ r = list(index._apply_index(qmap)[0].keys())
+ assert r == rlist, r
+ return index._apply_index
+
+ def checkStarQuery(self):
+ "Check a star query"
+ self.globTest({'text':'m*n'}, [0,2])
def checkAndQuery(self):
"Check an AND query"
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'time and country'})
- r=list(r[0].keys())
- assert r == [0,], r
+ self.globTest({'text':'time and country'}, [0,])
def checkOrQuery(self):
"Check an OR query"
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
+ self.globTest({'text':'time or country'}, [0,1,6])
- r = index._apply_index({'text':'time or country'})
- r=list(r[0].keys())
- assert r == [0,1,6], r
+ def checkDefOrQuery(self):
+ "Check a default OR query"
+ self.globTest({'text':'time country'}, [0,1,6])
def checkNearQuery(self):
- """Check a NEAR query.. (NOTE:ACTUALLY AN 'OR' TEST!!)"""
- # NEAR never worked, so Zopes post-2.3.1b3 define near to mean OR
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
+ """Check a NEAR query.. (NOTE:ACTUALLY AN 'AND' TEST!!)"""
+ # NEAR never worked, so Zopes post-2.3.1b3 define near to mean AND
+ self.globTest({'text':'time ... country'}, [0,])
+
+ def checkQuotesQuery(self):
+ """Check a quoted query"""
+ ai = self.globTest({'text':'"This is the time"'}, [0,])
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'time near country'})
- r=list(r[0].keys())
- assert r == [0,1,6], r
+ r = list(ai({'text':'"now is the time"'})[0].keys())
+ assert r == [], r
def checkAndNotQuery(self):
"Check an ANDNOT query"
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'time and not country'})
- r=list(r[0].keys())
- assert r == [6], r
+ self.globTest({'text':'time and not country'}, [6,])
def checkParenMatchingQuery(self):
"Check a query with parens"
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
+ ai = self.globTest({'text':'(time and country) men'}, [0,])
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'(time and country) men'})
- r=list(r[0].keys())
- assert r == [0], r
-
- r = index._apply_index({'text':'(time and not country) or men'})
- r=list(r[0].keys())
+ r = list(ai({'text':'(time and not country) or men'})[0].keys())
assert r == [0, 6], r
- def checkQuoteMatchingQuery(self):
- "Check a query with quotes.. this is known to fail under 2.3.1b3-"
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'"This is the time"'})
- r=list(r[0].keys())
- assert r == [0], r
-
- r = index._apply_index({'text':'"now is the time"'})
- r=list(r[0].keys())
- assert r == [], r
-
def checkTextIndexOperatorQuery(self):
"Check a query with 'textindex_operator' in the request"
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'time men','textindex_operator':'and'})
- r=list(r[0].keys())
- assert r == [0], r
+ self.globTest({'text':'time men', 'textindex_operator':'and'}, [0,])
def checkNonExistentWord(self):
""" Check for nonexistent word """
- index=self.dbopen()
- index._lexicon = SearchIndex.GlobbingLexicon.GlobbingLexicon()
-
- for i in range(len(self.sample_texts)):
- self.doc.text=self.sample_texts[i]
- index.index_object(i, self.doc)
- get_transaction().commit()
-
- self.dbclose()
-
- index=self.dbopen()
-
- r = index._apply_index({'text':'zop'})
- r=list(r[0].keys())
- assert r == [], r
+ self.globTest({'text':'zop'}, [])
+
+ def checkComplexQuery1(self):
+ """ Check complex query 1 """
+ self.globTest({'text':'((?ount* or get) and not wait) '
+ '"been *ert*"'}, [0, 1, 5, 6])
def test_suite():