[CMF-checkins] CVS: CMF/CMFDefault/tests - test_Document.py:1.25.18.1 test_utils.py:1.7.4.1

Yvo Schubbe schubbe@web.de
Sun, 2 Feb 2003 17:09:31 -0500


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

Modified Files:
      Tag: yuppie-collector041-branch
	test_Document.py test_utils.py 
Log Message:
second step:
- cleaned up code
- added some tests

=== CMF/CMFDefault/tests/test_Document.py 1.25 => 1.25.18.1 ===
--- CMF/CMFDefault/tests/test_Document.py:1.25	Fri Jun  7 18:43:04 2002
+++ CMF/CMFDefault/tests/test_Document.py	Sun Feb  2 17:09:28 2003
@@ -1,4 +1,11 @@
 from unittest import TestSuite, makeSuite, main
+
+try:
+    from Interface.Verify import verifyClass
+except ImportError:
+    # for Zope versions before 2.6.0
+    from Interface import verify_class_implementation as verifyClass
+
 from StringIO import StringIO
 from re import compile
 
@@ -261,6 +268,25 @@
         d.manage_editDocument( text_format='structured-text'
                              , text=STX_NO_HEADERS_BUT_COLON)
         self.assertEqual( d.EditableBody(), STX_NO_HEADERS_BUT_COLON )
+
+    def test_interface(self):
+        from Products.CMFCore.interfaces.Dynamic \
+                import DynamicType as IDynamicType
+        from Products.CMFCore.interfaces.Contentish \
+                import Contentish as IContentish
+        from Products.CMFCore.interfaces.DublinCore \
+                import DublinCore as IDublinCore
+        from Products.CMFCore.interfaces.DublinCore \
+                import CatalogableDublinCore as ICatalogableDublinCore
+        from Products.CMFCore.interfaces.DublinCore \
+                import MutableDublinCore as IMutableDublinCore
+
+        verifyClass(IDynamicType, Document)
+        verifyClass(IContentish, Document)
+        verifyClass(IDublinCore, Document)
+        verifyClass(ICatalogableDublinCore, Document)
+        # XXX: verifyClass doesn't work with WorkflowMethod wrappers.
+        # verifyClass(IMutableDublinCore, Document)
 
 
 class TestFTPGet( RequestTest ):


=== CMF/CMFDefault/tests/test_utils.py 1.7 => 1.7.4.1 ===
--- CMF/CMFDefault/tests/test_utils.py:1.7	Mon Jan  6 15:43:39 2003
+++ CMF/CMFDefault/tests/test_utils.py	Sun Feb  2 17:09:28 2003
@@ -1,9 +1,17 @@
-from unittest import TestCase,makeSuite,main
+from unittest import TestCase, makeSuite, main
 
 import Zope
+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 STX_WITH_HTML
+
 from Products.CMFDefault.utils import parseHeadersBody, tuplize, comma_split
+from Products.CMFDefault.utils import bodyfinder
+from Products.CMFDefault.utils import html_headcheck
 from Products.CMFDefault.utils import seq_strip
 
+
 class DefaultUtilsTests(TestCase):
     COMMON_HEADERS = '''Author: Tres Seaver
 Title: Test Products.CMFDefault.utils.parseHeadersBody'''
@@ -58,6 +66,22 @@
         assert( len( headers ) == 3, '%d!' % len( headers ) )
         assert( preloaded[ 'Author' ] != headers[ 'Author' ] )
         assert( preloaded[ 'text_format' ] == headers[ 'text_format' ] )
+
+    def test_bodyfinder(self):
+        self.assertEqual( bodyfinder(FAUX_HTML_LEADING_TEXT),
+                          FAUX_HTML_LEADING_TEXT )
+        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 )
+
+    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(STX_WITH_HTML), 0 )
+
 
 def test_suite():
     return makeSuite(DefaultUtilsTests)