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

Yvo Schubbe schubbe@web.de
Sun, 13 Jul 2003 11:50:35 -0400


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

Modified Files:
      Tag: yuppie-collector168-redo-branch
	test_Document.py 
Log Message:
redo using Method Aliases:
- un-hardwired manage_FTPget for 'text/html' (Collector #168)

=== CMF/CMFDefault/tests/test_Document.py 1.28 => 1.28.16.1 ===
--- CMF/CMFDefault/tests/test_Document.py:1.28	Sat Mar 15 05:43:22 2003
+++ CMF/CMFDefault/tests/test_Document.py	Sun Jul 13 11:50:01 2003
@@ -1,15 +1,23 @@
 from unittest import TestSuite, makeSuite, main
 
+import Zope
+try:
+    Zope.startup()
+except AttributeError:
+    # for Zope versions before 2.6.1
+    pass
 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 Globals import package_home
+from os.path import join
 from re import compile
+from StringIO import StringIO
 
-from Products.CMFCore.tests.base.testcase import RequestTest
+from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 
 from Products.CMFCore.tests.base.content import DOCTYPE
 from Products.CMFCore.tests.base.content import HTML_TEMPLATE
@@ -23,9 +31,14 @@
 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.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.tests.base.testcase import RequestTest
+from Products.CMFCore.tests.base.tidata import FTIDATA_CMF15
+from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
+from Products.CMFCore.TypesTool import TypesTool
 from Products.CMFDefault.Document import Document
 
+
 class DocumentTests(RequestTest):
 
     def setUp(self):
@@ -302,7 +315,26 @@
 
     def testHTML( self ):
         self.REQUEST['BODY']=BASIC_HTML
-        d = Document( 'foo' )
+
+        site = DummySite('site').__of__(self.root)
+        ttool = site._setObject( 'portal_types', TypesTool() )
+        fti = FTIDATA_CMF15[0].copy()
+        del fti['id']
+        ttool._setObject( 'Document', apply( FTI, ('Document',), fti) )
+
+        zpt = site._setObject( 'source_html',
+                               ZopePageTemplate('source_html') )
+        dir = package_home( globals() )
+        if dir.endswith('__main__'):
+            dir = dir[:-15]
+        else:
+            dir = dir[:-6]
+        file = join(dir, 'skins', 'zpt_content', 'source_html.pt')
+        data = open(file, 'r').read()
+        zpt.write(data)
+
+        d = site._setObject( 'foo', Document('foo') )
+        d._setPortalTypeName('Document')
         d.PUT(self.REQUEST, self.RESPONSE)
 
         rnlinesplit = compile( r'\r?\n?' )
@@ -346,6 +378,11 @@
 
         for header in simple_headers:
             self.failUnless( header in get_headers )
+
+        body1 = d.EditableBody()
+        self.REQUEST['BODY'] = d.manage_FTPget()
+        d.PUT(self.REQUEST, self.RESPONSE)
+        self.assertEqual( d.EditableBody(), body1 )
 
     def testSTX( self ):
         self.REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT