From 5c64829589e488c0668c82b0380ef696275a129f Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Tue, 4 Jan 2011 09:24:35 +0000
Subject: [PATCH] Edit web_page with file argument instead text_content
 argument te be closer to the reality.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41976 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5OOo/tests/testDms.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py
index c5862aef1b..07212b51ad 100644
--- a/product/ERP5OOo/tests/testDms.py
+++ b/product/ERP5OOo/tests/testDms.py
@@ -1531,9 +1531,23 @@ class TestDocument(TestDocumentMixin):
       </body>
     </html>
     """.decode('utf-8').encode('iso-8859-1')
-    web_page.edit(text_content=html_content)
+    # content encoded into another codec
+    # than utf-8 comes from necessarily an external file
+    # (Ingestion, or FileField), not from user interface 
+    # which is always utf-8.
+    # Edit web_page with a file to force conversion to base_format
+    # as it is done in reality
+
+    # Mimic the behaviour of a FileUpload from WebPage_view
+    file_like = StringIO.StringIO()
+    file_like.write(html_content)
+    setattr(file_like, 'filename', 'something.htm')
+    web_page.edit(file=file_like)
+    # run conversion to base format
+    transaction.commit() 
+    self.tic()
 
-    # Check that outputed stripped html is safe
+    # Check that outputted stripped html is safe
     safe_html = web_page.asStrippedHTML()
     self.assertTrue('My splendid title' in safe_html)
     self.assertTrue('script' not in safe_html, safe_html)
-- 
2.30.9