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
Nikola Balog
erp5
Commits
4d45ffd9
Commit
4d45ffd9
authored
Apr 03, 2019
by
Kazuhiko Shiozaki
Committed by
Kazuhiko Shiozaki
Jan 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Predicate: add a test to check multimembership criteria behaviour.
parent
9b5fbc18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testPredicate.py
...TemplateItem/portal_components/test.erp5.testPredicate.py
+43
-0
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testPredicate.py
View file @
4d45ffd9
...
@@ -329,6 +329,49 @@ class TestPredicates(TestPredicateMixIn):
...
@@ -329,6 +329,49 @@ class TestPredicates(TestPredicateMixIn):
[
'region/europe/western_europe/germany'
])
[
'region/europe/western_europe/germany'
])
self
.
assertFalse
(
pred
.
test
(
doc
))
self
.
assertFalse
(
pred
.
test
(
doc
))
def
test_BasicCategoryMultiMembership
(
self
):
# if the document is not member of all categories, the predicate returns
# false
doc1
=
self
.
createDocument
(
group
=
(
'nexedi/storever'
,
'other'
),
)
doc2
=
self
.
createDocument
(
group
=
'nexedi/storever'
,
)
doc3
=
self
.
createDocument
(
group
=
'other'
,
)
doc4
=
self
.
createDocument
()
self
.
tic
()
single_pred
=
self
.
createPredicate
(
membership_criterion_base_category_list
=
[
'group'
,],
membership_criterion_category_list
=
[
'group/nexedi/storever'
,
'group/other'
,
],
)
multi_pred
=
self
.
createPredicate
(
multimembership_criterion_base_category_list
=
[
'group'
,],
membership_criterion_category_list
=
[
'group/nexedi/storever'
,
'group/other'
,
],
)
single_pred_result
=
[
bool
(
single_pred
.
test
(
x
))
for
x
in
(
doc1
,
doc2
,
doc3
,
doc4
)]
multi_pred_result
=
[
bool
(
multi_pred
.
test
(
x
))
for
x
in
(
doc1
,
doc2
,
doc3
,
doc4
)]
self
.
assertEqual
(
single_pred_result
,
[
True
,
True
,
True
,
False
])
self
.
assertEqual
(
multi_pred_result
,
[
True
,
False
,
False
,
False
])
self
.
assertItemsEqual
(
[
doc1
,
doc2
,
doc3
],
[
x
.
getObject
()
for
x
in
single_pred
.
searchResults
(
portal_type
=
'Organisation'
)]
)
# XXX Ideally, the following query should return [doc1] only, but
# currently not optimised.
self
.
assertItemsEqual
(
[
doc1
,
doc2
,
doc3
],
[
x
.
getObject
()
for
x
in
multi_pred
.
searchResults
(
portal_type
=
'Organisation'
)]
)
def
test_BasicCategoryNullMembership
(
self
):
def
test_BasicCategoryNullMembership
(
self
):
# if the document is any member of the base category, the predicate returns
# if the document is any member of the base category, the predicate returns
# false
# false
...
...
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