Commit d65dc312 authored by Jérome Perrin's avatar Jérome Perrin

ods_style: fix support of untranslatable_columns

 - the test was using wrong attribute and it was using DummyLocalizer,
which breaks the site configuration. Fix the test and use mock
 - fix ods style not to translate untranslatable columns
parent 6b7ff67d
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
<tal:block tal:define="column_property python: column_item[1]; column_id python: column_item[0]"> <tal:block tal:define="column_property python: column_item[1]; column_id python: column_item[0]">
<tal:block tal:condition="python: column_property is not None" > <tal:block tal:condition="python: column_property is not None" >
<table:table-cell table:number-rows-spanned='1' table:style-name='report-column-title' table:number-columns-spanned='1' office:value-type='string' > <table:table-cell table:number-rows-spanned='1' table:style-name='report-column-title' table:number-columns-spanned='1' office:value-type='string' >
<text:p i18n:translate="" i18n:domain="ui" tal:content="column_property"> <text:p tal:content="column_property" tal:condition="python: column_id in untranslatable_columns"/>
</text:p> <text:p i18n:translate="" i18n:domain="ui" tal:content="column_property" tal:condition="python: column_id not in untranslatable_columns"/>
</table:table-cell> </table:table-cell>
</tal:block> </tal:block>
<tal:block tal:condition="python: column_property is None"> <tal:block tal:condition="python: column_property is None">
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
import io import io
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5Form.Selection import Selection from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase from Testing import ZopeTestCase
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
import httplib import httplib
import lxml.html import lxml.html
import mock
import PyPDF2 import PyPDF2
HTTP_OK = httplib.OK HTTP_OK = httplib.OK
...@@ -645,20 +645,33 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -645,20 +645,33 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
def test_untranslatable_columns(self): def test_untranslatable_columns(self):
self.portal.ListBoxZuite_reset() self.portal.ListBoxZuite_reset()
self.portal.Localizer = DummyLocalizer()
message_catalog = self.portal.Localizer.erp5_ui
# XXX odt style does not seem to display a listbox if it is empty ??? # XXX odt style does not seem to display a listbox if it is empty ???
self.portal.foo_module.newContent(portal_type='Foo') self.portal.foo_module.newContent(portal_type='Foo')
message = self.id()
self.portal.FooModule_viewFooList.listbox.ListBox_setPropertyList( self.portal.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_columns = ['do_not_translate | %s' % message,], field_columns=[
field_untranslatablecolumns = ['do_not_translate | %s' % message,], 'translate | COLUMN_TRANSLATED',
'do_not_translate | COLUMN_NOT_TRANSLATED',
],
field_untranslatable_columns = [
'do_not_translate | COLUMN_NOT_TRANSLATED',
],
) )
self.tic() self.tic()
self.portal.changeSkin(self.skin) self.portal.changeSkin(self.skin)
response = self.publish(
'/%s/foo_module/FooModule_viewFooList?portal_skin=' def gettext(message, **kw):
% self.portal.getId(), self.auth) if message == 'COLUMN_TRANSLATED':
return u'**àèüîó**'
return kw.get('default', message)
with mock.patch.object(
self.portal.Localizer.erp5_ui.__class__,
'gettext',
side_effect=gettext,
) as gettext_mock:
response = self.publish(
'/%s/foo_module/FooModule_viewFooList'
% self.portal.getId(), self.auth)
self.assertEqual(HTTP_OK, response.getStatus()) self.assertEqual(HTTP_OK, response.getStatus())
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
...@@ -671,10 +684,12 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -671,10 +684,12 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
parser = OOoParser() parser = OOoParser()
parser.openFromString(body) parser.openFromString(body)
content_xml = parser.oo_files['content.xml'] content_xml = parser.oo_files['content.xml']
self.assertIn(message, content_xml) self.assertIn(u'**àèüîó**', content_xml.decode('utf-8'))
# This untranslatable column have not been translated translated_message_list = [
self.assertNotIn(message, message_catalog._translated) x[1][0] for x in gettext_mock.mock_calls if x[1][0]]
self.assertIn('COLUMN_TRANSLATED', translated_message_list)
self.assertNotIn('COLUMN_NOT_TRANSLATED', translated_message_list)
def test_form_view_ZMI(self): def test_form_view_ZMI(self):
"""We can edit form_view in the ZMI.""" """We can edit form_view in the ZMI."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment