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
Hide 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,16 +384,27 @@ class PLexicon(Lexicon, Implicit, SimpleItem):
...
@@ -384,16 +384,27 @@ class PLexicon(Lexicon, Implicit, SimpleItem):
columns
.
append
(
words
[
i
:
i
+
rows
])
columns
.
append
(
words
[
i
:
i
+
rows
])
i
+=
rows
i
+=
rows
return
self
.
_queryLexicon
(
self
,
REQUEST
,
if
REQUEST
is
not
None
:
page
=
page
,
return
self
.
_queryLexicon
(
self
,
rows
=
rows
,
REQUEST
,
cols
=
cols
,
page
=
page
,
start_word
=
start
+
1
,
rows
=
rows
,
end_word
=
end
,
cols
=
cols
,
word_count
=
word_count
,
start_word
=
start
+
1
,
page_count
=
page_count
,
end_word
=
end
,
page_range
=
xrange
(
page_count
),
word_count
=
word_count
,
page_columns
=
columns
)
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'
)
security
.
declareProtected
(
LexiconMgmtPerm
,
'manage_main'
)
manage_main
=
DTMLFile
(
'dtml/manageLexicon'
,
globals
())
manage_main
=
DTMLFile
(
'dtml/manageLexicon'
,
globals
())
...
...
src/Products/ZCTextIndex/tests/testZCTextIndex.py
View file @
627bb14f
...
@@ -245,6 +245,7 @@ class ZCIndexTestsBase:
...
@@ -245,6 +245,7 @@ class ZCIndexTestsBase:
nbest, total = self.zc_index.query(w)
nbest, total = self.zc_index.query(w)
self.assertEqual(total, 0, "
did
not
expect
to
find
%
s
" % w)
self.assertEqual(total, 0, "
did
not
expect
to
find
%
s
" % w)
class CosineIndexTests(ZCIndexTestsBase, testIndex.CosineIndexTest):
class CosineIndexTests(ZCIndexTestsBase, testIndex.CosineIndexTest):
# A fairly involved test of the ranking calculations based on
# A fairly involved test of the ranking calculations based on
...
@@ -566,13 +567,44 @@ class OkapiQueryTests(QueryTestsBase):
...
@@ -566,13 +567,44 @@ class OkapiQueryTests(QueryTestsBase):
class PLexiconTests(unittest.TestCase):
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 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 Products.ZCTextIndex.interfaces import IZCLexicon
from zope.interface.verify import verifyClass
from zope.interface.verify import verifyClass
verifyClass(IZCLexicon, self._getTargetClass())
verifyClass(ILexicon, PLexicon)
def test_instance_conforms_to_IZCLexicon(self):
verifyClass(IZCLexicon, PLexicon)
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():
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