[Zope-Checkins] SVN: Zope/branches/2.12/src/Products/ZCTextIndex/tests/testZCTextIndex.py Flesh out tests for PLexicon.queryLexicon further.
Tres Seaver
tseaver at palladion.com
Mon Apr 12 08:26:40 EDT 2010
Log message for revision 110740:
Flesh out tests for PLexicon.queryLexicon further.
Changed:
U Zope/branches/2.12/src/Products/ZCTextIndex/tests/testZCTextIndex.py
-=-
Modified: Zope/branches/2.12/src/Products/ZCTextIndex/tests/testZCTextIndex.py
===================================================================
--- Zope/branches/2.12/src/Products/ZCTextIndex/tests/testZCTextIndex.py 2010-04-12 12:26:38 UTC (rev 110739)
+++ Zope/branches/2.12/src/Products/ZCTextIndex/tests/testZCTextIndex.py 2010-04-12 12:26:40 UTC (rev 110740)
@@ -594,9 +594,9 @@
from zope.interface.verify import verifyObject
verifyObject(IZCLexicon, self._makeOne())
- def test_queryLexicon_defaults(self):
- index = self._makeOne()
- info = index.queryLexicon(REQUEST=None, words=None)
+ def test_queryLexicon_defaults_empty(self):
+ lexicon = self._makeOne()
+ info = lexicon.queryLexicon(REQUEST=None, words=None)
self.assertEqual(info['page'], 0)
self.assertEqual(info['rows'], 20)
self.assertEqual(info['cols'], 4)
@@ -606,7 +606,64 @@
self.assertEqual(list(info['page_range']), [])
self.assertEqual(info['page_columns'], [])
+ def test_queryLexicon_defaults_non_empty(self):
+ WORDS = 'aaa bbb ccc ddd eee fff ggg'.split()
+ lexicon = self._makeOne()
+ lexicon.sourceToWordIds(WORDS)
+ info = lexicon.queryLexicon(REQUEST=None, words=None)
+ self.assertEqual(info['page'], 0)
+ self.assertEqual(info['rows'], 20)
+ self.assertEqual(info['cols'], 4)
+ self.assertEqual(info['start_word'], 1)
+ self.assertEqual(info['end_word'], 7)
+ self.assertEqual(info['word_count'], 7)
+ self.assertEqual(list(info['page_range']), [0])
+ self.assertEqual(info['page_columns'], [WORDS])
+ def test_queryLexicon_row_breaks(self):
+ WORDS = 'aaa bbb ccc ddd eee fff ggg'.split()
+ lexicon = self._makeOne()
+ lexicon.sourceToWordIds(WORDS)
+ info = lexicon.queryLexicon(REQUEST=None, words=None, rows=4)
+ self.assertEqual(info['page'], 0)
+ self.assertEqual(info['rows'], 4)
+ self.assertEqual(info['cols'], 4)
+ self.assertEqual(info['start_word'], 1)
+ self.assertEqual(info['end_word'], 7)
+ self.assertEqual(info['word_count'], 7)
+ self.assertEqual(list(info['page_range']), [0])
+ self.assertEqual(info['page_columns'], [WORDS[0:4], WORDS[4:]])
+
+ def test_queryLexicon_page_breaks(self):
+ WORDS = 'aaa bbb ccc ddd eee fff ggg'.split()
+ lexicon = self._makeOne()
+ lexicon.sourceToWordIds(WORDS)
+ info = lexicon.queryLexicon(REQUEST=None, words=None, rows=2, cols=2)
+ self.assertEqual(info['page'], 0)
+ self.assertEqual(info['rows'], 2)
+ self.assertEqual(info['cols'], 2)
+ self.assertEqual(info['start_word'], 1)
+ self.assertEqual(info['end_word'], 4)
+ self.assertEqual(info['word_count'], 7)
+ self.assertEqual(list(info['page_range']), [0, 1])
+ self.assertEqual(info['page_columns'], [WORDS[0:2], WORDS[2:4]])
+
+ def test_queryLexicon_page_break_not_first(self):
+ WORDS = 'aaa bbb ccc ddd eee fff ggg'.split()
+ lexicon = self._makeOne()
+ lexicon.sourceToWordIds(WORDS)
+ info = lexicon.queryLexicon(REQUEST=None, words=None,
+ page=1, rows=2, cols=2)
+ self.assertEqual(info['page'], 1)
+ self.assertEqual(info['rows'], 2)
+ self.assertEqual(info['cols'], 2)
+ self.assertEqual(info['start_word'], 5)
+ self.assertEqual(info['end_word'], 7)
+ self.assertEqual(info['word_count'], 7)
+ self.assertEqual(list(info['page_range']), [0, 1])
+ self.assertEqual(info['page_columns'], [WORDS[4:6], WORDS[6:]])
+
+
def test_suite():
s = unittest.TestSuite()
for klass in (CosineIndexTests, OkapiIndexTests,
More information about the Zope-Checkins
mailing list