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
Xavier Thompson
erp5
Commits
4a575f3e
Commit
4a575f3e
authored
Mar 17, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core_test: more Localizer tests
and adjust the test for better python3 compatibility
parent
e0e773c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testLocalizer.py
...TemplateItem/portal_components/test.erp5.testLocalizer.py
+23
-7
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testLocalizer.py
View file @
4a575f3e
...
...
@@ -28,6 +28,8 @@
import
unittest
import
six
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Persistence
import
PersistentMapping
...
...
@@ -50,12 +52,12 @@ class TestLocalizer(ERP5TypeTestCase):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"This is 1€."
)
# newly created key should be unicode.
self
.
assertNotIn
(
'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
assertNotIn
(
u'This is 1€.'
.
encode
(
'utf-8'
)
,
self
.
message_catalog
.
_messages
)
self
.
assertIn
(
u'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
message_catalog
.
message_edit
(
u'This is 1€.'
,
'fr'
,
u"C'est 1€."
,
''
)
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"C'est 1€."
)
self
.
assertNotIn
(
'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
assertNotIn
(
u'This is 1€.'
.
encode
(
'utf-8'
)
,
self
.
message_catalog
.
_messages
)
self
.
assertIn
(
u'This is 1€.'
,
self
.
message_catalog
.
_messages
)
def
test_migrated_non_ascii_msgid
(
self
):
...
...
@@ -66,23 +68,37 @@ class TestLocalizer(ERP5TypeTestCase):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"C'est 1€."
)
# translate() should not create a unicode key if str key already exists.
self
.
assertIn
(
'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
assertIn
(
u'This is 1€.'
.
encode
(
'utf-8'
)
,
self
.
message_catalog
.
_messages
)
self
.
assertNotIn
(
u'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
message_catalog
.
message_edit
(
u'This is 1€.'
,
'fr'
,
u"Ceci est 1€."
,
''
)
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"Ceci est 1€."
)
# message_edit() should not create a unicode key if str key already exists.
self
.
assertIn
(
'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
assertIn
(
u'This is 1€.'
.
encode
(
'utf-8'
)
,
self
.
message_catalog
.
_messages
)
self
.
assertNotIn
(
u'This is 1€.'
,
self
.
message_catalog
.
_messages
)
def
test_non_ascii_mapping
(
self
):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1${currency}.'
,
lang
=
'fr'
,
mapping
=
{
'currency'
:
'€'
}),
mapping
=
{
'currency'
:
'€'
}),
"This is 1€."
)
if
six
.
PY2
:
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1${currency}.'
,
lang
=
'fr'
,
mapping
=
{
'currency'
:
u'€'
}),
"This is 1€."
)
self
.
message_catalog
.
message_edit
(
u'This is 1${currency}.'
,
'fr'
,
u"C'est 1${currency}."
,
''
)
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1${currency}.'
,
lang
=
'fr'
,
mapping
=
{
'currency'
:
'€'
}),
mapping
=
{
'currency'
:
'€'
}),
"C'est 1€."
)
if
six
.
PY2
:
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1${currency}.'
,
lang
=
'fr'
,
mapping
=
{
'currency'
:
u'€'
}),
"C'est 1€."
)
def
test_non_literal_mapping
(
self
):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is ${obj}.'
,
lang
=
'fr'
,
...
...
@@ -104,7 +120,7 @@ class TestLocalizer(ERP5TypeTestCase):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"Ceci est 1€."
)
# po_import() converts existing str key to unicode key.
self
.
assertNotIn
(
'This is 1€.'
,
self
.
message_catalog
.
_messages
)
self
.
assertNotIn
(
u'This is 1€.'
.
encode
(
'utf-8'
)
,
self
.
message_catalog
.
_messages
)
self
.
assertIn
(
u'This is 1€.'
,
self
.
message_catalog
.
_messages
)
def
test_localizer_transle_in_activity
(
self
):
...
...
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