[CMF-checkins] CVS: CMF/CMFDefault/tests - test_Document.py:1.25.18.2 test_utils.py:1.7.4.2

Yvo Schubbe schubbe@web.de
Mon, 3 Feb 2003 13:32:17 -0500


Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv11061/CMFDefault/tests

Modified Files:
      Tag: yuppie-collector041-branch
	test_Document.py test_utils.py 
Log Message:
third step:
- added tests for xhtml content
- modified tests for bodyfinder
- made new tests pass

=== CMF/CMFDefault/tests/test_Document.py 1.25.18.1 => 1.25.18.2 ===
--- CMF/CMFDefault/tests/test_Document.py:1.25.18.1	Sun Feb  2 17:09:28 2003
+++ CMF/CMFDefault/tests/test_Document.py	Mon Feb  3 13:32:14 2003
@@ -22,6 +22,7 @@
 from Products.CMFCore.tests.base.content import STX_NO_HEADERS_BUT_COLON
 from Products.CMFCore.tests.base.content import SIMPLE_STRUCTUREDTEXT
 from Products.CMFCore.tests.base.content import SIMPLE_HTML
+from Products.CMFCore.tests.base.content import SIMPLE_XHTML
 
 from Products.CMFDefault.Document import Document
 
@@ -39,30 +40,25 @@
         self.assertEqual( d.text_format, 'structured-text' )
         self.assertEqual( d._stx_level, 1 )
 
-    def test_BasicHtmlPUT(self):
-        self.REQUEST['BODY'] = BASIC_HTML
+    def test_editBasicHTML(self):
         d = self.d
-        d.PUT(self.REQUEST, self.RESPONSE)
+        d.edit('html', BASIC_HTML)
+        self.failUnless( hasattr(d, 'cooked_text') )
         self.assertEqual( d.Format(), 'text/html' )
-        self.assertEqual( d.title, 'Title in tag' )
         self.assertEqual( d.text.find('</body>'), -1 )
-        self.assertEqual( d.Description(), 'Describe me' )
-        self.assertEqual( len(d.Contributors()), 3 )
-        self.assertEqual( d.Contributors()[-1], 'Benotz, Larry J (larry@benotz.stuff)' )
+        self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ' )
 
         # Since the format is html, the STX level operands should
         # have no effect.
         ct = d.CookedBody(stx_level=3, setlevel=1)
         self.assertEqual( d._stx_level, 1 )
 
-        subj = list(d.Subject())
-        self.assertEqual( len(subj), 4 )
-        subj.sort()
-        self.assertEqual( subj, [ 'content management'
-                                , 'framework'
-                                , 'unit tests'
-                                , 'zope'
-                                ] )
+    def test_editSimpleXHTML(self):
+        d = self.d
+        d.edit('html', SIMPLE_XHTML)
+        self.failUnless( hasattr(d, 'cooked_text') )
+        self.assertEqual( d.Format(), 'text/html' )
+        self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ')
 
     def test_UpperedHtml(self):
         self.REQUEST['BODY'] = BASIC_HTML.upper()
@@ -93,16 +89,6 @@
         self.assertEqual( d.Format(), 'text/html' )
         self.assertEqual( d.Description(), 'Describe me' )
 
-    def test_EditStripHTMLToBody(self):
-        # bodyfind should strip away everything but the contents of the body
-        # tag.
-        self.REQUEST['BODY'] = BASIC_HTML
-        d = self.d
-        d.PUT(self.REQUEST, self.RESPONSE)
-        self.failUnless( hasattr(d, 'cooked_text') )
-        self.assertEqual( d.Format(), 'text/html' )
-        self.assertEquals(d.cooked_text, '\n  <h1>Not a lot here</h1>\n ')
-
     def test_EditPlainDocumentWithEmbeddedHTML(self):
         d = self.d
         d.edit('structured-text', FAUX_HTML_LEADING_TEXT)
@@ -371,6 +357,40 @@
         RequestTest.setUp(self)
         self.d = Document('foo')
 
+    def test_PUTBasicHTML(self):
+        self.REQUEST['BODY'] = BASIC_HTML
+        d = self.d
+        r = d.PUT(self.REQUEST, self.RESPONSE)
+        self.failUnless( hasattr(d, 'cooked_text') )
+        self.assertEqual( d.Format(), 'text/html' )
+        self.assertEqual( d.title, 'Title in tag' )
+        self.assertEqual( d.text.find('</body>'), -1 )
+        self.assertEqual( d.Description(), 'Describe me' )
+        self.assertEqual( len(d.Contributors()), 3 )
+        self.assertEqual( d.Contributors()[-1],
+                          'Benotz, Larry J (larry@benotz.stuff)' )
+        self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ' )
+        self.assertEqual( r.status, 204 )
+
+        subj = list(d.Subject())
+        self.assertEqual( len(subj), 4 )
+        subj.sort()
+        self.assertEqual( subj, [ 'content management'
+                                , 'framework'
+                                , 'unit tests'
+                                , 'zope'
+                                ] )
+
+    def test_PUTSimpleXHTML(self):
+        self.REQUEST['BODY'] = SIMPLE_XHTML
+        d = self.d
+        r = d.PUT(self.REQUEST, self.RESPONSE)
+        self.failUnless( hasattr(d, 'cooked_text') )
+        self.assertEqual( d.Format(), 'text/html' )
+        self.assertEqual( d.Description(), 'Describe me' )
+        self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ' )
+        self.assertEqual( r.status, 204 )
+
     def test_PutStructuredTextWithHTML(self):
             
         self.REQUEST['BODY'] = STX_WITH_HTML
@@ -392,14 +412,6 @@
         html = '%s\n\n  \n   %s' % (DOCTYPE, BASIC_HTML)
         self.REQUEST['BODY'] = html
         
-        r = self.d.PUT(self.REQUEST, self.RESPONSE)
-        self.assertEqual( self.d.Format(), 'text/html' )
-        self.assertEqual( self.d.Description(), 'Describe me' )
-        self.assertEqual( r.status, 204 )
-
-    def test_PutHtml(self):
-        
-        self.REQUEST['BODY'] = BASIC_HTML
         r = self.d.PUT(self.REQUEST, self.RESPONSE)
         self.assertEqual( self.d.Format(), 'text/html' )
         self.assertEqual( self.d.Description(), 'Describe me' )


=== CMF/CMFDefault/tests/test_utils.py 1.7.4.1 => 1.7.4.2 ===
--- CMF/CMFDefault/tests/test_utils.py:1.7.4.1	Sun Feb  2 17:09:28 2003
+++ CMF/CMFDefault/tests/test_utils.py	Mon Feb  3 13:32:14 2003
@@ -4,6 +4,7 @@
 from Products.CMFCore.tests.base.content import FAUX_HTML_LEADING_TEXT
 from Products.CMFCore.tests.base.content import SIMPLE_HTML
 from Products.CMFCore.tests.base.content import SIMPLE_STRUCTUREDTEXT
+from Products.CMFCore.tests.base.content import SIMPLE_XHTML
 from Products.CMFCore.tests.base.content import STX_WITH_HTML
 
 from Products.CMFDefault.utils import parseHeadersBody, tuplize, comma_split
@@ -69,17 +70,21 @@
 
     def test_bodyfinder(self):
         self.assertEqual( bodyfinder(FAUX_HTML_LEADING_TEXT),
-                          FAUX_HTML_LEADING_TEXT )
+                          '\n  <h1>Not a lot here</h1>\n ' )
         self.assertEqual( bodyfinder(SIMPLE_HTML),
                           '\n  <h1>Not a lot here</h1>\n ' )
         self.assertEqual( bodyfinder(SIMPLE_STRUCTUREDTEXT),
                           SIMPLE_STRUCTUREDTEXT )
-        self.assertEqual( bodyfinder(STX_WITH_HTML), STX_WITH_HTML )
+        self.assertEqual( bodyfinder(SIMPLE_XHTML),
+                          '\n  <h1>Not a lot here</h1>\n ' )
+        self.assertEqual( bodyfinder(STX_WITH_HTML),
+                          '<p>Hello world, I am Bruce.</p>' )
 
     def test_html_headcheck(self):
         self.assertEqual( html_headcheck(FAUX_HTML_LEADING_TEXT), 0 )
         self.assertEqual( html_headcheck(SIMPLE_HTML), 1 )
         self.assertEqual( html_headcheck(SIMPLE_STRUCTUREDTEXT), 0 )
+        self.assertEqual( html_headcheck(SIMPLE_XHTML), 1 )
         self.assertEqual( html_headcheck(STX_WITH_HTML), 0 )