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
Mikolaï Krol
erp5
Commits
183af9c2
Commit
183af9c2
authored
Apr 03, 2019
by
Kazuhiko Shiozaki
Committed by
Kazuhiko Shiozaki
Jan 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Predicate: add a test to check multimembership criteria behaviour.
parent
3bacf028
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
product/ERP5/tests/testPredicate.py
product/ERP5/tests/testPredicate.py
+43
-0
No files found.
product/ERP5/tests/testPredicate.py
View file @
183af9c2
...
...
@@ -330,6 +330,49 @@ class TestPredicates(TestPredicateMixIn):
[
'region/europe/western_europe/germany'
])
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
):
# if the document is any member of the base category, the predicate returns
# 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