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
Tatuya Kamada
erp5
Commits
3b935ad2
Commit
3b935ad2
authored
Mar 05, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a local property fixing fix.
Also extend test case to cover exactly what is expected to happen.
parent
3dab2e92
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
product/ERP5Type/Constraint/PropertyTypeValidity.py
product/ERP5Type/Constraint/PropertyTypeValidity.py
+7
-3
product/ERP5Type/tests/testConstraint.py
product/ERP5Type/tests/testConstraint.py
+8
-4
No files found.
product/ERP5Type/Constraint/PropertyTypeValidity.py
View file @
3b935ad2
...
...
@@ -73,7 +73,8 @@ class PropertyTypeValidity(Constraint):
" (Type cast failed with error ${type_cast_error})"
message_incorrect_type_fixed
=
"Attribute ${attribute_name}"
\
" should be of type ${expected_type} but is of type ${actual_type} (Fixed)"
message_value_modified
=
"Value of '${key}' was modified from '${old}' to '${new}'."
message_local_property_migrated
=
"Property ${property_id} was migrated from local properties."
message_local_property_modified
=
"Property ${property_id} was modified from ${old_value} to ${new_value}."
def
_checkConsistency
(
self
,
obj
,
fixit
=
0
):
"""Check the object's consistency.
...
...
@@ -96,6 +97,9 @@ class PropertyTypeValidity(Constraint):
len
([
x
for
x
in
obj
.
_propertyMap
()
if
x
[
'id'
]
==
property_id
])
>
1
:
obj
.
_local_properties
=
tuple
([
x
for
x
in
obj
.
_local_properties
if
x
[
'id'
]
!=
property_id
])
error_list
.
append
(
self
.
_generateError
(
obj
,
self
.
_getMessage
(
'message_local_property_migrated'
),
dict
(
property_id
=
property_id
)))
property_was_local
=
True
if
property_type
in
self
.
_permissive_type_list
:
...
...
@@ -141,8 +145,8 @@ class PropertyTypeValidity(Constraint):
oldvalue
=
getattr
(
obj
,
property_id
,
value
)
if
oldvalue
!=
value
:
error_list
.
append
(
self
.
_generateError
(
obj
,
self
.
_getMessage
(
'message_
value
_modified'
),
dict
(
key
=
property_id
,
old
=
oldvalue
,
new
=
value
)))
self
.
_getMessage
(
'message_
local_property
_modified'
),
dict
(
property_id
=
property_id
,
old_value
=
oldvalue
,
new_value
=
value
)))
obj
.
setProperty
(
property_id
,
value
)
return
error_list
product/ERP5Type/tests/testConstraint.py
View file @
3b935ad2
...
...
@@ -1215,7 +1215,8 @@ class TestConstraint(PropertySheetTestCase):
portal_type
=
"Standard Property"
,
property_id
=
"local_property"
,
elementary_type
=
"string"
)
constraint
.
fixConsistency
(
obj
)
self
.
assertEqual
([
'Property local_property was migrated from local properties.'
],
[
str
(
q
.
getMessage
())
for
q
in
constraint
.
fixConsistency
(
obj
)])
self
.
assertEquals
((),
obj
.
_local_properties
)
self
.
assertEquals
(
'1'
,
obj
.
getLocalProperty
())
obj
.
edit
(
local_property
=
'something else'
)
...
...
@@ -1237,7 +1238,8 @@ class TestConstraint(PropertySheetTestCase):
portal_type
=
"Standard Property"
,
property_id
=
"local_property"
,
elementary_type
=
"float"
)
constraint
.
fixConsistency
(
obj
)
self
.
assertEqual
([
'Property local_property was migrated from local properties.'
],
[
str
(
q
.
getMessage
())
for
q
in
constraint
.
fixConsistency
(
obj
)])
self
.
assertEquals
((),
obj
.
_local_properties
)
self
.
assertEquals
(
1.234
,
obj
.
getLocalProperty
())
obj
.
edit
(
local_property
=
3
)
...
...
@@ -1269,7 +1271,8 @@ class TestConstraint(PropertySheetTestCase):
ti
.
_setTypeAllowedContentTypeList
(
allowed_types
+
[
'Organisation'
])
transaction
.
commit
()
try
:
constraint
.
fixConsistency
(
obj
)
self
.
assertEqual
([
'Property local_property was migrated from local properties.'
],
[
str
(
q
.
getMessage
())
for
q
in
constraint
.
fixConsistency
(
obj
)])
self
.
assertEquals
(
'foo'
,
obj
.
getDefaultOrganisationTitle
())
self
.
assertEquals
(
'foo'
,
obj
.
default_organisation
.
getTitle
())
finally
:
...
...
@@ -1293,7 +1296,8 @@ class TestConstraint(PropertySheetTestCase):
portal_type
=
"Category Property"
,
property_id
=
"testing_category"
)
# fix consistency
constraint
.
fixConsistency
(
obj
)
self
.
assertEqual
([
'Property local_property was migrated from local properties.'
],
[
str
(
q
.
getMessage
())
for
q
in
constraint
.
fixConsistency
(
obj
)])
# now we can use testing_category as any category accessor
self
.
assertEquals
(
obj
,
obj
.
getTestingCategoryValue
())
...
...
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