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
1
Merge Requests
1
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
Boxiang Sun
erp5
Commits
e4275bbe
Commit
e4275bbe
authored
Jan 29, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testFields: test for ProxyField.has_value
This was not much tested
parent
fe941384
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py
...estTemplateItem/portal_components/test.erp5.testFields.py
+86
-0
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py
View file @
e4275bbe
...
@@ -914,6 +914,92 @@ class TestProxyField(ERP5TypeTestCase):
...
@@ -914,6 +914,92 @@ class TestProxyField(ERP5TypeTestCase):
self
.
assertFalse
(
field
.
is_message_delegated
(
test_error
))
self
.
assertFalse
(
field
.
is_message_delegated
(
test_error
))
self
.
assertEqual
(
field
.
get_error_message
(
test_error
),
test_message2
)
self
.
assertEqual
(
field
.
get_error_message
(
test_error
),
test_message2
)
def
_test_has_value
(
self
,
setValueOnLibraryField
,
setValueOnField
):
"""Tests has_value method
We use this:
Base_viewGeek/my_title [field]
| overriding "css_class"
v
Base_viewGeekFieldLibrary/my_title [library_field]
| overriding "description"
v
Base_viewGeekFieldLibrary/my_base_title [library_base_field]
and check that has_value is correct for both field (a proxy field using
another proxy field as target) and library_field (a proxy field using
a traditional field as target).
This will be tested for both cases where the values are set as "normal values"
or as TALES, the setup of values is done by setValueOnLibraryField and
setValueField functions.
"""
self
.
addField
(
self
.
container
.
Base_viewProxyFieldLibrary
,
'my_title_base'
,
'library base field'
,
'StringField'
)
library_field
=
self
.
addField
(
self
.
container
.
Base_viewProxyFieldLibrary
,
'my_title'
,
''
,
'ProxyField'
)
library_field
.
manage_edit_xmlrpc
(
dict
(
form_id
=
'Base_viewProxyFieldLibrary'
,
field_id
=
'my_title_base'
,))
field
=
self
.
addField
(
self
.
container
.
Base_view
,
'my_title'
,
''
,
'ProxyField'
)
field
.
manage_edit_xmlrpc
(
dict
(
form_id
=
'Base_viewProxyFieldLibrary'
,
field_id
=
'my_title'
))
setValueOnLibraryField
(
library_field
)
setValueOnField
(
field
)
# sanity check
self
.
assertEqual
(
field
.
get_value
(
'title'
),
'library base field'
)
self
.
assertEqual
(
field
.
get_value
(
'description'
),
'library proxy field'
)
self
.
assertEqual
(
field
.
get_value
(
'css_class'
),
'form proxy field'
)
# proxy fields have values from proxyied fields
self
.
assertTrue
(
field
.
has_value
(
'title'
))
self
.
assertTrue
(
field
.
has_value
(
'description'
))
self
.
assertTrue
(
field
.
has_value
(
'css_class'
))
self
.
assertTrue
(
library_field
.
has_value
(
'title'
))
self
.
assertTrue
(
library_field
.
has_value
(
'description'
))
self
.
assertTrue
(
library_field
.
has_value
(
'css_class'
))
# proxy fields have their "own" values
self
.
assertTrue
(
field
.
has_value
(
'form_id'
))
self
.
assertTrue
(
field
.
has_value
(
'field_id'
))
self
.
assertFalse
(
field
.
has_value
(
'not_exists'
))
self
.
assertFalse
(
library_field
.
has_value
(
'not_exists'
))
def
test_has_value
(
self
):
def
setValueOnLibraryField
(
library_field
):
library_field
.
manage_edit_surcharged_xmlrpc
({
'description'
:
'library proxy field'
})
def
setValueOnField
(
field
):
field
.
manage_edit_surcharged_xmlrpc
({
'css_class'
:
'form proxy field'
})
return
self
.
_test_has_value
(
setValueOnLibraryField
,
setValueOnField
)
def
test_has_value_TALES
(
self
):
def
setValueOnLibraryField
(
library_field
):
library_field
.
_surcharged_tales
(
{
'description'
:
TALESMethod
(
'string:library proxy field'
)},
[
'description'
])
def
setValueOnField
(
field
):
field
.
_surcharged_tales
(
{
'css_class'
:
TALESMethod
(
'string:form proxy field'
)},
[
'css_class'
])
return
self
.
_test_has_value
(
setValueOnLibraryField
,
setValueOnField
)
class
TestFieldValueCache
(
ERP5TypeTestCase
):
class
TestFieldValueCache
(
ERP5TypeTestCase
):
"""Tests field value caching system
"""Tests field value caching system
"""
"""
...
...
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