[Erp5-report] r31247 fabien - in /erp5/trunk/products/ERP5OOo/tests: ./ test_document/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Dec 11 16:48:47 CET 2009


Author: fabien
Date: Fri Dec 11 16:48:47 2009
New Revision: 31247

URL: http://svn.erp5.org?rev=31247&view=rev
Log:
- add a second test to check that is possible to enter text with new lines (multi
line)
- ODT skin is not needed

Modified:
    erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py
    erp5/trunk/products/ERP5OOo/tests/test_document/Foo_001.odg

Modified: erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py?rev=31247&r1=31246&r2=31247&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py [utf8] Fri Dec 11 16:48:47 2009
@@ -144,7 +144,6 @@
 
     request = self.app.REQUEST
     # 1. Normal case: "my_title" field to the "my_title" reference in the ODF document
-    self.portal.changeSkin('ODT')
     odf_document = foo_printout.index_html(REQUEST=request)
     self.assertTrue(odf_document is not None)
     builder = OOoBuilder(odf_document)
@@ -230,6 +229,69 @@
     self.assertTrue(content_xml.find("Français test2") > 0)
     self._validate(odf_document)
 
+  def test_02_TextFieldWithMultiLines(self):
+    """
+    mapping a field containing many lines ('\n') to a textbox
+    """
+    portal = self.getPortal()
+
+    # add a description field in the form
+    foo_form = self.portal.foo_module.test1.Foo_view
+    if foo_form._getOb("my_description", None) is None:
+      foo_form.manage_addField('my_description', 'Description', 'TextAreaField')
+    foo_module = self.portal.foo_module
+    if foo_module._getOb('test1', None) is None:
+      foo_module.newContent(id='test1', portal_type='Foo')
+    test1 =  foo_module.test1
+    test1.setDescription('A text a bit more longer\n\nWith a newline !')
+    transaction.commit()
+    self.tic()
+
+    style_dict = {'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}line-break': {},
+                  '{urn:oasis:names:tc:opendocument:xmlns:text:1.0}p': {},
+                  '{urn:oasis:names:tc:opendocument:xmlns:text:1.0}span':
+                    {'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-name': 'T4'}
+                 }
+
+    # test target
+    foo_printout = portal.foo_module.test1.Foo_viewAsODGPrintout
+    original_file_content = self.getODFDocumentFromPrintout(foo_printout)
+    self._validate(original_file_content)
+
+    # extract content.xml from original odg document
+    original_doc_builder = OOoBuilder(original_file_content)
+    original_content_xml = original_doc_builder.extract("content.xml")
+    # get style of the title in the orignal test document
+    original_document_style_dict = self.getStyleDictFromFieldName(original_content_xml,
+        'my_description')
+
+    # check the style is good before the odg generation
+    self.assertEqual(original_document_style_dict, style_dict)
+
+    request = self.app.REQUEST
+    # 1. Normal case: "my_title" field to the "my_title" reference in the ODF document
+    odf_document = foo_printout.index_html(REQUEST=request)
+    self.assertTrue(odf_document is not None)
+    # validate the generated document
+    self._validate(odf_document)
+    builder = OOoBuilder(odf_document)
+    content_xml = builder.extract("content.xml")
+    content = etree.XML(content_xml)
+    final_document_style_dict = self.getStyleDictFromFieldName(content_xml,
+        'my_description')
+
+    # check the style is keept after the odg generation
+    self.assertEqual(final_document_style_dict, style_dict)
+
+    # check the two lines are prensent in the generated document
+    self.assertTrue(content_xml.find('A text a bit more longer') > 0)
+    self.assertTrue(content_xml.find('With a newline !') > 0)
+
+    # check there is two line-break in the element my_description
+    text_xpath = '//draw:frame[@draw:name="my_description"]//text:line-break'
+    node_list = content.xpath(text_xpath, namespaces=content.nsmap)
+    self.assertEqual(len(node_list), 2)
+
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestFormPrintoutAsODG))

Modified: erp5/trunk/products/ERP5OOo/tests/test_document/Foo_001.odg
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/test_document/Foo_001.odg?rev=31247&r1=31246&r2=31247&view=diff
==============================================================================
Binary files - no diff available.




More information about the Erp5-report mailing list