[CMF-checkins] CVS: CMF/CMFDefault/tests - test_Document.py:1.31
Yvo Schubbe
cvs-admin at zope.org
Tue Dec 2 07:49:10 EST 2003
Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv10366/CMFDefault/tests
Modified Files:
test_Document.py
Log Message:
fixed skin path used in testHTML
=== CMF/CMFDefault/tests/test_Document.py 1.30 => 1.31 ===
--- CMF/CMFDefault/tests/test_Document.py:1.30 Fri Sep 26 10:27:10 2003
+++ CMF/CMFDefault/tests/test_Document.py Tue Dec 2 07:49:09 2003
@@ -1,5 +1,6 @@
from unittest import TestSuite, makeSuite, main
+import Testing
import Zope
try:
Zope.startup()
@@ -12,30 +13,32 @@
# for Zope versions before 2.6.0
from Interface import verify_class_implementation as verifyClass
-from Globals import package_home
-from os.path import join
+from os.path import abspath
+from os.path import dirname
+from os.path import join as path_join
from re import compile
from StringIO import StringIO
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
-from Products.CMFCore.tests.base.content import DOCTYPE
-from Products.CMFCore.tests.base.content import HTML_TEMPLATE
from Products.CMFCore.tests.base.content import BASIC_HTML
-from Products.CMFCore.tests.base.content import FAUX_HTML_LEADING_TEXT
-from Products.CMFCore.tests.base.content import ENTITY_IN_TITLE
from Products.CMFCore.tests.base.content import BASIC_STRUCTUREDTEXT
-from Products.CMFCore.tests.base.content import STX_WITH_HTML
-from Products.CMFCore.tests.base.content import STX_NO_HEADERS
-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 DOCTYPE
+from Products.CMFCore.tests.base.content import ENTITY_IN_TITLE
+from Products.CMFCore.tests.base.content import FAUX_HTML_LEADING_TEXT
+from Products.CMFCore.tests.base.content import HTML_TEMPLATE
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_NO_HEADERS
+from Products.CMFCore.tests.base.content import STX_NO_HEADERS_BUT_COLON
+from Products.CMFCore.tests.base.content import STX_WITH_HTML
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 import utils
from Products.CMFDefault.Document import Document
@@ -84,7 +87,7 @@
self.assertEqual( len(d.Contributors()), 3 )
def test_EntityInTitle(self):
- self.REQUEST['BODY'] = ENTITY_IN_TITLE
+ self.REQUEST['BODY'] = ENTITY_IN_TITLE
d = self.d
d.PUT(self.REQUEST, self.RESPONSE)
self.assertEqual( d.title, '&Auuml;rger' )
@@ -132,17 +135,17 @@
_file = StringIO( html )
d.edit(text_format='html', text='', file=_file)
self.assertEqual( d.CookedBody(), body )
-
+
def test_plain_text(self):
"""test that plain text forrmat works"""
- d = self.d
+ d = self.d
d.edit(text_format='plain', text='*some plain text*\nwith a newline')
self.assertEqual( d.CookedBody(), '*some plain text*<br />with a newline')
def test_EditStructuredTextWithHTML(self):
d = self.d
d.edit(text_format='structured-text', text=STX_WITH_HTML)
-
+
self.assertEqual( d.Format(), 'text/plain' )
def test_StructuredText(self):
@@ -223,7 +226,7 @@
self.assertEqual( d.EditableBody(), STX_NO_HEADERS )
self.failUnless( d.CookedBody() )
self.assertEqual( d.Format(), 'text/plain' )
-
+
def test_STX_NoHeaders( self ):
self.REQUEST['BODY']=STX_NO_HEADERS
d = self.d
@@ -239,14 +242,14 @@
self.failUnless( 'STX' in d.Subject() )
d.PUT(self.REQUEST, self.RESPONSE)
-
+
self.assertEqual( d.Format(), 'text/plain' )
self.assertEqual( d.Title(), 'Plain STX' )
self.assertEqual( d.Description(), 'Look, Ma, no headers!' )
self.assertEqual( len( d.Subject() ), 2 )
self.failUnless( 'plain' in d.Subject() )
self.failUnless( 'STX' in d.Subject() )
-
+
def test_STX_NoHeaders_but_colon( self ):
d = self.d
d.editMetadata( title="Plain STX"
@@ -256,7 +259,7 @@
d.edit(text_format='structured-text', text=STX_NO_HEADERS_BUT_COLON)
self.assertEqual( d.EditableBody(), STX_NO_HEADERS_BUT_COLON )
-
+
def test_ZMI_edit( self ):
d = self.d
d.editMetadata( title="Plain STX"
@@ -324,12 +327,8 @@
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')
+ dir = abspath( dirname(utils.__file__) )
+ _file = path_join(dir, 'skins', 'zpt_content', 'source_html.pt')
data = open(_file, 'r').read()
zpt.write(data)
@@ -348,7 +347,7 @@
title_pattern = compile( r'<title>(.*)</title>' )
simple_headers = []
while simple_lines and simple_lines[0] != '<BODY>':
- header = simple_lines[0].strip().lower()
+ header = simple_lines[0].strip().lower()
match = meta_pattern.search( header )
if match:
simple_headers.append( match.groups() )
@@ -453,7 +452,7 @@
self.assertEqual( r.status, 204 )
def test_PutStructuredTextWithHTML(self):
-
+
self.REQUEST['BODY'] = STX_WITH_HTML
r = self.d.PUT(self.REQUEST, self.RESPONSE)
@@ -469,10 +468,10 @@
self.assertEqual( r.status, 204 )
def test_PutHtmlWithDoctype(self):
-
+
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' )
@@ -488,4 +487,3 @@
if __name__ == '__main__':
main(defaultTest='test_suite')
-
More information about the CMF-checkins
mailing list