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
89d6eeb8
Commit
89d6eeb8
authored
Feb 28, 2003
by
Casey Duncan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge keyindex unique value fix (issue #828)
parent
7dc3d1c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
...ython/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
+7
-1
lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
...ucts/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
+33
-5
No files found.
lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
View file @
89d6eeb8
...
...
@@ -90,7 +90,13 @@ class KeywordIndex(UnIndex):
if
callable
(
newKeywords
):
newKeywords
=
newKeywords
()
if
hasattr
(
newKeywords
,
'capitalize'
):
# is it string-like ?
newKeywords
=
(
newKeywords
,
)
newKeywords
=
[
newKeywords
]
else
:
# Uniqueify keywords
unique
=
{}
for
k
in
newKeywords
:
unique
[
k
]
=
None
newKeywords
=
unique
.
keys
()
return
newKeywords
def
unindex_objectKeywords
(
self
,
documentId
,
keywords
):
...
...
lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
View file @
89d6eeb8
...
...
@@ -27,7 +27,15 @@ class Dummy:
__repr__
=
__str__
class
TestCase
(
unittest
.
TestCase
):
def
sortedUnique
(
seq
):
unique
=
{}
for
i
in
seq
:
unique
[
i
]
=
None
unique
=
unique
.
keys
()
unique
.
sort
()
return
unique
class
TestKeywordIndex
(
unittest
.
TestCase
):
"""
Test KeywordIndex objects.
"""
...
...
@@ -41,7 +49,7 @@ class TestCase( unittest.TestCase ):
self
.
_values
=
[
(
0
,
Dummy
(
[
'a'
]
)
)
,
(
1
,
Dummy
(
[
'a'
,
'b'
]
)
)
,
(
2
,
Dummy
(
[
'a'
,
'b'
,
'c'
]
)
)
,
(
3
,
Dummy
(
[
'a'
,
'b'
,
'c'
,
'a'
]
)
)
,
(
3
,
Dummy
(
[
'a'
,
'b'
,
'c'
,
'a'
]
)
)
,
(
4
,
Dummy
(
[
'a'
,
'b'
,
'c'
,
'd'
]
)
)
,
(
5
,
Dummy
(
[
'a'
,
'b'
,
'c'
,
'e'
]
)
)
,
(
6
,
Dummy
(
[
'a'
,
'b'
,
'c'
,
'e'
,
'f'
]
))
...
...
@@ -135,7 +143,10 @@ class TestCase( unittest.TestCase ):
self
.
_index
.
unindex_object
(
1234
)
# nothrow
for
k
,
v
in
values
:
assert
self
.
_index
.
getEntryForObject
(
k
)
==
v
.
foo
()
entry
=
self
.
_index
.
getEntryForObject
(
k
)
entry
.
sort
()
kw
=
sortedUnique
(
v
.
foo
())
self
.
assertEqual
(
entry
,
kw
)
assert
(
len
(
self
.
_index
.
uniqueValues
(
'foo'
)
)
==
len
(
values
)
-
1
,
len
(
values
)
-
1
)
...
...
@@ -184,7 +195,7 @@ class TestCase( unittest.TestCase ):
assert
result
[
0
]
==
8
def
testIntersectionWithRange
(
self
):
"""Test an 'and' search, ensuring that 'range' doesn't mess it up."""
# Test an 'and' search, ensuring that 'range' doesn't mess it up.
self
.
_populateIndex
()
record
=
{
'foo'
:
{
'query'
:
[
'e'
,
'f'
]
...
...
@@ -199,6 +210,23 @@ class TestCase( unittest.TestCase ):
#
record
[
'foo'
][
'range'
]
=
'min:max'
self
.
_checkApply
(
record
,
self
.
_values
[
6
:
7
]
)
def
testDuplicateKeywords
(
self
):
self
.
_catch_log_errors
()
try
:
self
.
_index
.
index_object
(
0
,
Dummy
([
'a'
,
'a'
,
'b'
,
'b'
]))
self
.
_index
.
unindex_object
(
0
)
finally
:
self
.
_ignore_log_errors
()
def
test_suite
():
return
unittest
.
makeSuite
(
TestCase
)
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestKeywordIndex
)
)
return
suite
def
main
():
unittest
.
main
(
defaultTest
=
'test_suite'
)
if
__name__
==
'__main__'
:
main
()
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