Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Niegsch
erp5
Commits
acd28780
Commit
acd28780
authored
May 09, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify _testSubContentReindexing
parent
69dcc9db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
39 deletions
+16
-39
product/ERP5Type/tests/utils.py
product/ERP5Type/tests/utils.py
+16
-39
No files found.
product/ERP5Type/tests/utils.py
View file @
acd28780
...
...
@@ -635,50 +635,27 @@ def updateCellList(portal, line, cell_type, cell_range_method, cell_dict_list):
cell
.
edit
(
predicate_category_list
=
category_list
,
variation_category_list
=
category_list
)
def
catalogObjectListWrapper
(
self
,
object_list
,
method_id_list
=
None
,
disable_cache
=
0
,
check_uid
=
1
,
idxs
=
None
):
"""Wrapper to mark inside of portal object list of catalogged objects"""
import
transaction
portal
=
self
.
getPortalObject
()
for
q
in
object_list
:
portal
.
catalogged_object_path_dict
[
q
.
getPath
()]
=
1
transaction
.
commit
()
class
SubcontentReindexingWrapper
(
object
):
def
wrap_catalogObjectList
(
self
):
self
.
original_catalogObjectList
=
Catalog
.
catalogObjectList
Catalog
.
catalogObjectList
=
catalogObjectListWrapper
def
unwrap_catalogObjectList
(
self
):
Catalog
.
catalogObjectList
=
self
.
original_catalogObjectList
def
_testSubContentReindexing
(
self
,
parent_document
,
children_document_list
):
"""Helper method which shall be called *before* tic or commit"""
# cleanup existing reindexing
transaction
.
commit
()
self
.
tic
()
parent_document
.
reindexObject
()
self
.
portal
.
catalogged_object_path_dict
=
PersistentMapping
()
transaction
.
commit
()
expected_path_list
=
[
q
.
getPath
()
for
q
in
children_document_list
+
[
parent_document
]]
def
catalogObjectList
(
self
,
object_list
,
*
args
,
**
kw
):
"""Wrapper to track list of catalogged objects"""
for
q
in
object_list
:
catalogged_object_path_set
.
add
(
q
.
getPath
())
return
orig_catalogObjectList
(
self
,
object_list
,
*
args
,
**
kw
)
orig_catalogObjectList
=
Catalog
.
__dict__
[
'catalogObjectList'
]
expected_path_set
=
set
(
q
.
getPath
()
for
q
in
children_document_list
+
[
parent_document
])
self
.
assertEqual
(
expected_path_set
,
set
(
x
.
getPath
()
for
x
in
self
.
portal
.
portal_catalog
(
path
=
expected_path_set
)))
try
:
# wrap call to catalogObjectList
self
.
wrap_catalogObjectList
()
self
.
stepTic
()
self
.
assertSameSet
(
self
.
portal
.
catalogged_object_path_dict
.
keys
(),
expected_path_list
)
# do real assertions
self
.
portal
.
catalogged_object_path_dict
=
PersistentMapping
()
transaction
.
commit
()
Catalog
.
catalogObjectList
=
catalogObjectList
catalogged_object_path_set
=
set
()
parent_document
.
reindexObject
()
self
.
stepTic
()
self
.
assertSameSet
(
self
.
portal
.
catalogged_object_path_dict
.
keys
(),
expected_path_list
)
transaction
.
commit
()
self
.
tic
()
self
.
assertEqual
(
expected_path_set
,
catalogged_object_path_set
)
finally
:
# unwrap catalogObjectList
self
.
unwrap_catalogObjectList
()
Catalog
.
catalogObjectList
=
orig_catalogObjectList
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