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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
936a8cea
Commit
936a8cea
authored
Aug 13, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail with explicit error when searchPredicateList is passed a context with non existant categories
parent
52358c8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
product/CMFCategory/CategoryTool.py
product/CMFCategory/CategoryTool.py
+8
-3
product/ERP5/tests/testDomainTool.py
product/ERP5/tests/testDomainTool.py
+32
-0
No files found.
product/CMFCategory/CategoryTool.py
View file @
936a8cea
...
@@ -1587,9 +1587,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
...
@@ -1587,9 +1587,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
if
len
(
category_uid_list
)
==
0
:
if
len
(
category_uid_list
)
==
0
:
# New base category, append it to the ordered list.
# New base category, append it to the ordered list.
ordered_base_category_uid_list
.
append
(
base_category_uid
)
ordered_base_category_uid_list
.
append
(
base_category_uid
)
category_uid_list
.
append
(
self
.
getCategoryUid
(
category
))
category_uid
=
self
.
getCategoryUid
(
category
)
else
:
category_uid_list
.
append
(
category_uid
)
LOG
(
'CategoryTool'
,
0
,
'Received invalid category %r'
%
(
category
,
))
if
category_uid
is
None
and
category
!=
'NULL'
:
raise
TypeError
(
"Invalid category passed to buildAdvancedSQLSelector: %r"
%
category
)
# Generate "left join" and "where" expressions.
# Generate "left join" and "where" expressions.
left_join_list
=
[
catalog_table_name
]
left_join_list
=
[
catalog_table_name
]
where_expression_list
=
[]
where_expression_list
=
[]
...
...
product/ERP5/tests/testDomainTool.py
View file @
936a8cea
...
@@ -649,6 +649,38 @@ class TestDomainTool(TestPredicateMixIn):
...
@@ -649,6 +649,38 @@ class TestDomainTool(TestPredicateMixIn):
tested_base_category_list
=
[
'WAAA'
,
'BOOO'
],
tested_base_category_list
=
[
'WAAA'
,
'BOOO'
],
src__
=
1
))
src__
=
1
))
def
test_searchPredicateInvalidCategories
(
self
):
predicate
=
self
.
portal
.
sale_supply_module
.
newContent
(
portal_type
=
'Sale Supply'
)
predicate
.
validate
()
self
.
assertNotEquals
(
predicate
.
asPredicate
(),
None
)
context
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
region
=
(
'broken/category'
))
# An invalid category should raise explicitly, for all parameters of
# searchPredicateList ( the code paths are different )
self
.
assertRaises
(
TypeError
,
self
.
portal
.
portal_domains
.
searchPredicateList
,
context
=
context
,
portal_type
=
predicate
.
portal_type
)
self
.
assertRaises
(
TypeError
,
self
.
portal
.
portal_domains
.
searchPredicateList
,
context
=
context
,
portal_type
=
predicate
.
portal_type
,
acquired
=
False
)
self
.
assertRaises
(
TypeError
,
self
.
portal
.
portal_domains
.
searchPredicateList
,
context
=
context
,
portal_type
=
predicate
.
portal_type
,
tested_base_category_list
=
[
'region'
])
self
.
assertRaises
(
TypeError
,
self
.
portal
.
portal_domains
.
searchPredicateList
,
context
=
context
,
portal_type
=
predicate
.
portal_type
,
tested_base_category_list
=
[
'region'
],
acquired
=
False
)
# This is also the case if there are multiple categories (another code
# path)
context
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
region
=
(
'broken/category'
,
'region'
))
self
.
assertRaises
(
TypeError
,
self
.
portal
.
portal_domains
.
searchPredicateList
,
context
=
context
,
portal_type
=
predicate
.
portal_type
)
def
test_setRelationToBaseDomain
(
self
):
def
test_setRelationToBaseDomain
(
self
):
# category accessors can be useed to set relations to base domains.
# category accessors can be useed to set relations to base domains.
base_domain
=
self
.
portal
.
portal_domains
.
newContent
(
base_domain
=
self
.
portal
.
portal_domains
.
newContent
(
...
...
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