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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Noah Brackenbury
erp5
Commits
3dab2e92
Commit
3dab2e92
authored
Mar 05, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore no local properties while fixing.
parent
89f275b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
product/ERP5Type/Constraint/PropertyTypeValidity.py
product/ERP5Type/Constraint/PropertyTypeValidity.py
+3
-1
product/ERP5Type/tests/testConstraint.py
product/ERP5Type/tests/testConstraint.py
+21
-0
No files found.
product/ERP5Type/Constraint/PropertyTypeValidity.py
View file @
3dab2e92
...
@@ -81,6 +81,7 @@ class PropertyTypeValidity(Constraint):
...
@@ -81,6 +81,7 @@ class PropertyTypeValidity(Constraint):
error_list
=
[]
error_list
=
[]
# For each attribute name, we check type
# For each attribute name, we check type
for
prop
in
obj
.
propertyMap
():
for
prop
in
obj
.
propertyMap
():
property_was_local
=
False
property_id
=
prop
[
'id'
]
property_id
=
prop
[
'id'
]
if
prop
.
get
(
'multivalued'
,
0
):
if
prop
.
get
(
'multivalued'
,
0
):
property_type
=
'lines'
property_type
=
'lines'
...
@@ -95,6 +96,7 @@ class PropertyTypeValidity(Constraint):
...
@@ -95,6 +96,7 @@ class PropertyTypeValidity(Constraint):
len
([
x
for
x
in
obj
.
_propertyMap
()
if
x
[
'id'
]
==
property_id
])
>
1
:
len
([
x
for
x
in
obj
.
_propertyMap
()
if
x
[
'id'
]
==
property_id
])
>
1
:
obj
.
_local_properties
=
tuple
([
x
for
x
in
obj
.
_local_properties
obj
.
_local_properties
=
tuple
([
x
for
x
in
obj
.
_local_properties
if
x
[
'id'
]
!=
property_id
])
if
x
[
'id'
]
!=
property_id
])
property_was_local
=
True
if
property_type
in
self
.
_permissive_type_list
:
if
property_type
in
self
.
_permissive_type_list
:
continue
continue
...
@@ -135,7 +137,7 @@ class PropertyTypeValidity(Constraint):
...
@@ -135,7 +137,7 @@ class PropertyTypeValidity(Constraint):
error_list
.
append
(
self
.
_generateError
(
obj
,
error_list
.
append
(
self
.
_generateError
(
obj
,
self
.
_getMessage
(
error_message
),
mapping
))
self
.
_getMessage
(
error_message
),
mapping
))
elif
fixit
:
elif
fixit
and
property_was_local
:
oldvalue
=
getattr
(
obj
,
property_id
,
value
)
oldvalue
=
getattr
(
obj
,
property_id
,
value
)
if
oldvalue
!=
value
:
if
oldvalue
!=
value
:
error_list
.
append
(
self
.
_generateError
(
obj
,
error_list
.
append
(
self
.
_generateError
(
obj
,
...
...
product/ERP5Type/tests/testConstraint.py
View file @
3dab2e92
...
@@ -1178,6 +1178,27 @@ class TestConstraint(PropertySheetTestCase):
...
@@ -1178,6 +1178,27 @@ class TestConstraint(PropertySheetTestCase):
expression
=
'error: " '
)
expression
=
'error: " '
)
self
.
assertRaises
(
CompilerError
,
constraint
.
checkConsistency
,
obj
)
self
.
assertRaises
(
CompilerError
,
constraint
.
checkConsistency
,
obj
)
def
test_PropertyTypeValidityFixLocalPropertiesIgnoresNoLocal
(
self
):
"""Tests PropertyTypeValidity can repairs local property when this property
is added on the class later, and this property is already in the good type.
"""
constraint
=
self
.
_createGenericConstraint
(
klass_name
=
'PropertyTypeValidity'
,
id
=
'type_validity_constraint'
,
)
obj
=
self
.
_makeOne
()
self
.
_addProperty
(
obj
.
getPortalType
(),
"FixLocalPropertiesString"
,
portal_type
=
"Standard Property"
,
property_id
=
"local_property"
,
elementary_type
=
"string"
)
obj
.
edit
(
local_property
=
'1'
)
self
.
assertFalse
(
'_local_properties'
in
obj
.
__dict__
)
self
.
assertEquals
([],
constraint
.
checkConsistency
(
obj
))
self
.
assertEqual
([],
constraint
.
fixConsistency
(
obj
))
self
.
assertFalse
(
'_local_properties'
in
obj
.
__dict__
)
self
.
assertEquals
(
'1'
,
obj
.
getLocalProperty
())
obj
.
edit
(
local_property
=
'something else'
)
self
.
assertEquals
(
'something else'
,
obj
.
getLocalProperty
())
def
test_PropertyTypeValidityFixLocalPropertiesString
(
self
):
def
test_PropertyTypeValidityFixLocalPropertiesString
(
self
):
"""Tests PropertyTypeValidity can repairs local property when this property
"""Tests PropertyTypeValidity can repairs local property when this property
is added on the class later, and this property is already in the good type.
is added on the class later, and this property is already in the good type.
...
...
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