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

Tres Seaver tseaver at zope.com
Sat Sep 25 16:32:07 EDT 2004


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

Modified Files:
	test_Document.py 
Log Message:
 - Forward-port performance fix for 'Document.get_size'.


=== Products/CMFDefault/tests/test_Document.py 1.37 => 1.38 ===
--- Products/CMFDefault/tests/test_Document.py:1.37	Thu Aug 12 11:07:41 2004
+++ Products/CMFDefault/tests/test_Document.py	Sat Sep 25 16:32:07 2004
@@ -73,6 +73,7 @@
         self.assertEqual( d.text, '' )
         self.assertEqual( d.text_format, 'structured-text' )
         self.assertEqual( d._stx_level, 1 )
+        self.assertEqual( d.get_size(), 0 )
 
     def test_editBasicHTML(self):
         d = self._makeOne('foo')
@@ -160,17 +161,29 @@
         d.edit(text_format='html', text='', file=_file)
         self.assertEqual( d.CookedBody(), body )
 
+    def test_Html_Fragment(self):
+        """test that edits with HTML fragments behave nicely"""
+        FRAGMENT = '<div id="placeholder">CONTENT</div>'
+        d = self._makeOne('foo')
+        d.edit(text_format='html', text=FRAGMENT)
+        self.assertEqual( d.CookedBody(), FRAGMENT )
+        self.assertEqual( d.get_size(), len(FRAGMENT) )
+
     def test_plain_text(self):
         """test that plain text forrmat works"""
+        PLAIN_TEXT = '*some plain text*\nwith a newline'
         d = self._makeOne('foo')
-        d.edit(text_format='plain', text='*some plain text*\nwith a newline')
-        self.assertEqual( d.CookedBody(), '*some plain text*<br />with a newline')
+        d.edit(text_format='plain', text=PLAIN_TEXT)
+        self.assertEqual( d.CookedBody(),
+                          '*some plain text*<br />with a newline')
+        self.assertEqual( d.get_size(), len(PLAIN_TEXT) )
 
     def test_EditStructuredTextWithHTML(self):
         d = self._makeOne('foo')
         d.edit(text_format='structured-text', text=STX_WITH_HTML)
 
         self.assertEqual( d.Format(), 'text/plain' )
+        self.assertEqual( d.get_size(), len(STX_WITH_HTML) )
 
     def test_StructuredText(self):
         self.REQUEST['BODY'] = BASIC_STRUCTUREDTEXT



More information about the CMF-checkins mailing list