Update of /cvs-repository/Products/ZCTextIndex/tests In directory cvs.zope.org:/tmp/cvs-serv31115/lib/python/Products/ZCTextIndex/tests
Modified Files: Tag: Zope-2_7-branch testZCTextIndex.py Log Message: - Collector #1784: fixed handling of multiple attributes in ZCTextIndex === Products/ZCTextIndex/tests/testZCTextIndex.py 1.37.2.1 => 1.37.2.2 === --- Products/ZCTextIndex/tests/testZCTextIndex.py:1.37.2.1 Mon Nov 17 17:34:12 2003 +++ Products/ZCTextIndex/tests/testZCTextIndex.py Tue May 17 14:10:41 2005 @@ -39,6 +39,11 @@ def __init__(self, text): self.text = text +class Indexable2: + def __init__(self, text1, text2): + self.text1 = text1 + self.text2 = text2 + class LexiconHolder(Acquisition.Implicit): def __init__(self, lexicon): self.lexicon = lexicon @@ -115,6 +120,7 @@ 'lexicon') self.index = self.zc_index.index + def parserFailure(self, query): self.assertRaises(ParseError, self.zc_index.query, query) @@ -123,6 +129,27 @@ self.assertEqual(num, n) if n: self.assertEqual(r[0][0], 1) + + def testMultipleAttributes(self): + lexicon = PLexicon('lexicon', '', + Splitter(), + CaseNormalizer(), + StopWordRemover()) + caller = LexiconHolder(self.lexicon) + zc_index = ZCTextIndex('name', + None, + caller, + self.IndexFactory, + 'text1,text2', + 'lexicon') + doc = Indexable2('foo bar', 'alpha omega') + zc_index.index_object(1, doc) + nbest, total = zc_index.query('foo') + self.assertEqual(len(nbest), 1) + nbest, total = zc_index.query('foo alpha') + self.assertEqual(len(nbest), 1) + nbest, total = zc_index.query('foo alpha gamma') + self.assertEqual(len(nbest), 0) def testStopWords(self): # the only non-stopword is question _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins