Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
627bb14f
Commit
627bb14f
authored
Apr 12, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flesh out tests for PLexicon.queryLexicon.
parent
0c14ff7d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
13 deletions
+56
-13
src/Products/ZCTextIndex/ZCTextIndex.py
src/Products/ZCTextIndex/ZCTextIndex.py
+21
-10
src/Products/ZCTextIndex/tests/testZCTextIndex.py
src/Products/ZCTextIndex/tests/testZCTextIndex.py
+35
-3
No files found.
src/Products/ZCTextIndex/ZCTextIndex.py
View file @
627bb14f
...
...
@@ -384,7 +384,9 @@ class PLexicon(Lexicon, Implicit, SimpleItem):
columns
.
append
(
words
[
i
:
i
+
rows
])
i
+=
rows
return
self
.
_queryLexicon
(
self
,
REQUEST
,
if
REQUEST
is
not
None
:
return
self
.
_queryLexicon
(
self
,
REQUEST
,
page
=
page
,
rows
=
rows
,
cols
=
cols
,
...
...
@@ -394,6 +396,15 @@ class PLexicon(Lexicon, Implicit, SimpleItem):
page_count
=
page_count
,
page_range
=
xrange
(
page_count
),
page_columns
=
columns
)
return
dict
(
page
=
page
,
rows
=
rows
,
cols
=
cols
,
start_word
=
start
+
1
,
end_word
=
end
,
word_count
=
word_count
,
page_count
=
page_count
,
page_range
=
xrange
(
page_count
),
page_columns
=
columns
)
security
.
declareProtected
(
LexiconMgmtPerm
,
'manage_main'
)
manage_main
=
DTMLFile
(
'dtml/manageLexicon'
,
globals
())
...
...
src/Products/ZCTextIndex/tests/testZCTextIndex.py
View file @
627bb14f
...
...
@@ -245,6 +245,7 @@ class ZCIndexTestsBase:
nbest, total = self.zc_index.query(w)
self.assertEqual(total, 0, "
did
not
expect
to
find
%
s
" % w)
class CosineIndexTests(ZCIndexTestsBase, testIndex.CosineIndexTest):
# A fairly involved test of the ranking calculations based on
...
...
@@ -566,13 +567,44 @@ class OkapiQueryTests(QueryTestsBase):
class PLexiconTests(unittest.TestCase):
def test_z3interfaces(self):
def _getTargetClass(self):
from Products.ZCTextIndex.ZCTextIndex import PLexicon
return PLexicon
def _makeOne(self, id='testing', title='Testing', *pipeline):
return self._getTargetClass()(id, title, *pipeline)
def test_class_conforms_to_ILexicon(self):
from Products.ZCTextIndex.interfaces import ILexicon
from zope.interface.verify import verifyClass
verifyClass(ILexicon, self._getTargetClass())
def test_instance_conforms_to_ILexicon(self):
from Products.ZCTextIndex.interfaces import ILexicon
from zope.interface.verify import verifyObject
verifyObject(ILexicon, self._makeOne())
def test_class_conforms_to_IZCLexicon(self):
from Products.ZCTextIndex.interfaces import IZCLexicon
from zope.interface.verify import verifyClass
verifyClass(IZCLexicon, self._getTargetClass())
verifyClass(ILexicon, PLexicon)
verifyClass(IZCLexicon, PLexicon)
def test_instance_conforms_to_IZCLexicon(self):
from Products.ZCTextIndex.interfaces import IZCLexicon
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)
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'], 0)
self.assertEqual(info['word_count'], 0)
self.assertEqual(list(info['page_range']), [])
self.assertEqual(info['page_columns'], [])
def test_suite():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment