[CMF-checkins] CVS: Products/CMFDefault/tests - test_Document.py:1.37.2.2

Jens Vagelpohl jens at dataflake.org
Wed Oct 27 05:32:36 EDT 2004


Update of /cvs-repository/Products/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv9686/CMFDefault/tests

Modified Files:
      Tag: CMF-1_5-branch
	test_Document.py 
Log Message:
- Document/NewsItem: If the "plain text" format is selected the
  content will no longer be tested for HTML and reduced to text
  between opening and closing "body" tags
  (http://www.zope.org/Collectors/CMF/214)

- Document/NewsItem: A call to setFormat will now re-cook the
  document content if the format has been changed (arising from
  discussion about http://www.zope.org/Collectors/CMF/214)


=== Products/CMFDefault/tests/test_Document.py 1.37.2.1 => 1.37.2.2 ===
--- Products/CMFDefault/tests/test_Document.py:1.37.2.1	Sat Sep 25 11:34:10 2004
+++ Products/CMFDefault/tests/test_Document.py	Wed Oct 27 05:32:36 2004
@@ -28,6 +28,7 @@
 from StringIO import StringIO
 
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
+from DocumentTemplate.DT_Util import html_quote
 
 from Products.CMFCore.tests.base.content import BASIC_HTML
 from Products.CMFCore.tests.base.content import BASIC_STRUCTUREDTEXT
@@ -160,6 +161,25 @@
         _file = StringIO( html )
         d.edit(text_format='html', text='', file=_file)
         self.assertEqual( d.CookedBody(), body )
+
+    def test_Htmltag_removal_and_formatchange(self):
+        """ Test for http://www.zope.org/Collectors/CMF/214 """
+        d = self._makeOne('foo')
+        quoted_html = html_quote(BASIC_HTML)
+
+        # Put HTML into a plain text document
+        d.edit(text_format='plain', text=BASIC_HTML)
+        new_body = d.CookedBody()
+        self.failIf(new_body==BASIC_HTML)
+        self.failUnless(new_body.startswith(quoted_html[:5]))
+
+        # Now we change the format. The body *must* change because
+        # the format change will trigger re-cooking
+        old_body = d.CookedBody()
+        d.setFormat('html')
+        new_body = d.CookedBody()
+        self.failIf(old_body==new_body)
+        self.failIf(new_body==BASIC_HTML)
 
     def test_Html_Fragment(self):
         """test that edits with HTML fragments behave nicely"""



More information about the CMF-checkins mailing list