Back to index

plone3  3.1.7
test_Document.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ Unit tests for Document module.
00014 
00015 $Id: test_Document.py 77186 2007-06-28 19:06:19Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 
00021 from os.path import abspath
00022 from os.path import dirname
00023 from os.path import join as path_join
00024 from re import compile
00025 from StringIO import StringIO
00026 
00027 from DocumentTemplate.DT_Util import html_quote
00028 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
00029 
00030 from Products.CMFCore.testing import ConformsToContent
00031 from Products.CMFCore.tests.base.content import BASIC_HTML
00032 from Products.CMFCore.tests.base.content import BASIC_STRUCTUREDTEXT
00033 from Products.CMFCore.tests.base.content import DOCTYPE
00034 from Products.CMFCore.tests.base.content import ENTITY_IN_TITLE
00035 from Products.CMFCore.tests.base.content import FAUX_HTML_LEADING_TEXT
00036 from Products.CMFCore.tests.base.content import HTML_TEMPLATE
00037 from Products.CMFCore.tests.base.content import SIMPLE_HTML
00038 from Products.CMFCore.tests.base.content import SIMPLE_STRUCTUREDTEXT
00039 from Products.CMFCore.tests.base.content import SIMPLE_XHTML
00040 from Products.CMFCore.tests.base.content import STX_NO_HEADERS
00041 from Products.CMFCore.tests.base.content import STX_NO_HEADERS_BUT_COLON
00042 from Products.CMFCore.tests.base.content import STX_WITH_HTML
00043 from Products.CMFCore.tests.base.dummy import DummySite
00044 from Products.CMFCore.tests.base.testcase import RequestTest
00045 from Products.CMFCore.tests.base.tidata import FTIDATA_CMF15
00046 from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
00047 from Products.CMFCore.TypesTool import TypesTool
00048 from Products.CMFDefault import utils
00049 
00050 
00051 class RequestTestBase(RequestTest):
00052 
00053     def _getTargetClass(self):
00054         from Products.CMFDefault.Document import Document
00055 
00056         return Document
00057 
00058     def _makeOne(self, *args, **kw):
00059         return self._getTargetClass()(*args, **kw)
00060 
00061 
00062 class DocumentTests(ConformsToContent, RequestTestBase):
00063 
00064     def test_z2interfaces(self):
00065         from Interface.Verify import verifyClass
00066         from Products.CMFDefault.interfaces.Document import IDocument
00067         from Products.CMFDefault.interfaces.Document import IMutableDocument
00068 
00069         verifyClass(IDocument, self._getTargetClass())
00070         verifyClass(IMutableDocument, self._getTargetClass())
00071 
00072     def test_z3interfaces(self):
00073         from zope.interface.verify import verifyClass
00074         from Products.CMFDefault.interfaces import IDocument
00075         from Products.CMFDefault.interfaces import IMutableDocument
00076 
00077         verifyClass(IDocument, self._getTargetClass())
00078         verifyClass(IMutableDocument, self._getTargetClass())
00079 
00080     def test_Empty(self):
00081         d = self._makeOne('foo', text_format='structured-text')
00082 
00083         self.assertEqual( d.title, '' )
00084         self.assertEqual( d.description, '' )
00085         self.assertEqual( d.text, '' )
00086         self.assertEqual( d.text_format, 'structured-text' )
00087         self.assertEqual( d._stx_level, 1 )
00088         self.assertEqual( d.get_size(), 0 )
00089 
00090     def test_editBasicHTML(self):
00091         d = self._makeOne('foo')
00092         d.edit('html', BASIC_HTML)
00093 
00094         self.failUnless( hasattr(d, 'cooked_text') )
00095         self.assertEqual( d.Format(), 'text/html' )
00096         self.assertEqual( d.text.find('</body>'), -1 )
00097         self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ' )
00098 
00099         # Since the format is html, the STX level operands should
00100         # have no effect.
00101         ct = d.CookedBody(stx_level=3, setlevel=1)
00102         self.assertEqual( d._stx_level, 1 )
00103 
00104     def test_editSimpleXHTML(self):
00105         d = self._makeOne('foo')
00106         d.edit('html', SIMPLE_XHTML)
00107 
00108         self.failUnless( hasattr(d, 'cooked_text') )
00109         self.assertEqual( d.Format(), 'text/html' )
00110         self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ')
00111 
00112     def test_UpperedHtml(self):
00113         self.REQUEST['BODY'] = BASIC_HTML.upper()
00114         d = self._makeOne('foo')
00115         d.PUT(self.REQUEST, self.RESPONSE)
00116 
00117         self.assertEqual( d.Format(), 'text/html' )
00118         self.assertEqual( d.title, 'TITLE IN TAG' )
00119         self.assertEqual( d.text.find('</BODY'), -1 )
00120         self.assertEqual( d.Description(), 'DESCRIBE ME' )
00121         self.assertEqual( len(d.Contributors()), 3 )
00122 
00123     def test_EntityInTitle(self):
00124         self.REQUEST['BODY'] = ENTITY_IN_TITLE
00125         d = self._makeOne('foo')
00126         d.PUT(self.REQUEST, self.RESPONSE)
00127 
00128         self.assertEqual( d.title, '&Auuml;rger' )
00129 
00130     def test_HtmlWithDoctype(self):
00131         self.REQUEST['BODY'] = '%s\n%s' % (DOCTYPE, BASIC_HTML)
00132         d = self._makeOne('foo')
00133         d.PUT(self.REQUEST, self.RESPONSE)
00134 
00135         self.assertEqual( d.Description(), 'Describe me' )
00136 
00137     def test_HtmlWithoutNewlines(self):
00138         self.REQUEST['BODY'] = ''.join((BASIC_HTML.split('\n')))
00139         d = self._makeOne('foo')
00140         d.PUT(self.REQUEST, self.RESPONSE)
00141 
00142         self.assertEqual( d.Format(), 'text/html' )
00143         self.assertEqual( d.Description(), 'Describe me' )
00144 
00145     def test_EditPlainDocumentWithEmbeddedHTML(self):
00146         d = self._makeOne('foo')
00147         d.edit('structured-text', FAUX_HTML_LEADING_TEXT)
00148         fully_edited = d.cooked_text
00149         d._edit(FAUX_HTML_LEADING_TEXT)
00150         partly_edited = d.cooked_text
00151         self.assertEquals(fully_edited, partly_edited)
00152 
00153     def test_BigHtml(self):
00154         d = self._makeOne('foo')
00155         s = []
00156         looper = '<li> number %s</li>'
00157         for i in range(12000): s.append(looper % i)
00158         body = '<ul>\n%s\n</ul>' % '\n'.join(s)
00159         self.REQUEST['BODY'] = HTML_TEMPLATE % {'title': 'big document',
00160                                 'body': body}
00161         d.PUT(self.REQUEST, self.RESPONSE)
00162         self.assertEqual( d.CookedBody(), body )
00163 
00164     def test_BigHtml_via_upload(self):
00165         d = self._makeOne('foo')
00166         s = []
00167         looper = '<li> number %s</li>'
00168         for i in range(12000): s.append(looper % i)
00169         body = '<ul>\n%s\n</ul>' % '\n'.join(s)
00170         html = HTML_TEMPLATE % {'title': 'big document',
00171                                 'body': body}
00172         _file = StringIO( html )
00173         d.edit(text_format='html', text='', file=_file)
00174         self.assertEqual( d.CookedBody(), body )
00175 
00176     def test_Htmltag_removal_and_formatchange(self):
00177         # Test for http://www.zope.org/Collectors/CMF/214
00178         d = self._makeOne('foo')
00179         quoted_html = html_quote(BASIC_HTML)
00180 
00181         # Put HTML into a plain text document
00182         d.edit(text_format='plain', text=BASIC_HTML)
00183         new_body = d.CookedBody()
00184         self.failIf(new_body==BASIC_HTML)
00185         self.failUnless(new_body.startswith(quoted_html[:5]))
00186 
00187         # Now we change the format. The body *must* change because
00188         # the format change will trigger re-cooking
00189         old_body = d.CookedBody()
00190         d.setFormat('html')
00191         new_body = d.CookedBody()
00192         self.failIf(old_body==new_body)
00193         self.failIf(new_body==BASIC_HTML)
00194 
00195     def test_Html_Fragment(self):
00196         # Test that edits with HTML fragments behave nicely
00197         FRAGMENT = '<div id="placeholder">CONTENT</div>'
00198         d = self._makeOne('foo')
00199         d.edit(text_format='html', text=FRAGMENT)
00200         self.assertEqual( d.CookedBody(), FRAGMENT )
00201         self.assertEqual( d.get_size(), len(FRAGMENT) )
00202 
00203     def test_plain_text(self):
00204         # test that plain text forrmat works
00205         PLAIN_TEXT = '*some plain text*\nwith a newline'
00206         d = self._makeOne('foo')
00207         d.edit(text_format='plain', text=PLAIN_TEXT)
00208         self.assertEqual( d.CookedBody(),
00209                           '*some plain text*<br />with a newline')
00210         self.assertEqual( d.get_size(), len(PLAIN_TEXT) )
00211 
00212     def test_EditStructuredTextWithHTML(self):
00213         d = self._makeOne('foo')
00214         d.edit(text_format='structured-text', text=STX_WITH_HTML)
00215 
00216         self.assertEqual( d.Format(), 'text/plain' )
00217         self.assertEqual( d.get_size(), len(STX_WITH_HTML) )
00218 
00219     def test_StructuredText(self):
00220         self.REQUEST['BODY'] = BASIC_STRUCTUREDTEXT
00221         d = self._makeOne('foo')
00222         d.PUT(self.REQUEST, self.RESPONSE)
00223 
00224         self.failUnless( hasattr(d, 'cooked_text') )
00225         self.assertEqual( d.Format(), 'text/plain' )
00226         self.assertEqual( d.Title(), 'My Document' )
00227         self.assertEqual( d.Description(), 'A document by me' )
00228         self.assertEqual( len(d.Contributors()), 3 )
00229         self.failUnless( d.cooked_text.find('<p>') >= 0 )
00230         self.failUnless( d.CookedBody().find('<h1') >= 0 )
00231 
00232         # Make sure extra HTML is NOT found
00233         self.failUnless( d.cooked_text.find('<title>') < 0 )
00234         self.failUnless( d.cooked_text.find('<body>') < 0 )
00235 
00236         # test subject/keyword headers
00237         subj = list(d.Subject())
00238         self.assertEqual( len(subj), 4 )
00239         subj.sort()
00240         self.assertEqual( subj, [ 'content management'
00241                                 , 'framework'
00242                                 , 'unit tests'
00243                                 , 'zope'
00244                                 ] )
00245 
00246     def test_STX_Levels(self):
00247         d = self._makeOne('foo')
00248         d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
00249         self.assertEqual( d._stx_level, 1 )
00250 
00251         ct = d.CookedBody()
00252         self.failUnless( d.CookedBody().find('<h1') >= 0 )
00253         self.assertEqual( d._stx_level, 1 )
00254 
00255         ct = d.CookedBody(stx_level=2)
00256         self.failIf( ct.find('<h1') >= 0 )
00257         self.failUnless( ct.find('<h2') >= 0 )
00258         self.assertEqual( d._stx_level, 1 )
00259 
00260         ct = d.CookedBody(stx_level=2, setlevel=1)
00261         self.failIf( ct.find('<h1') >= 0 )
00262         self.failUnless( ct.find('<h2') >= 0 )
00263         self.assertEqual( d._stx_level, 2 )
00264 
00265         ct = d.CookedBody()
00266         self.assertEqual( d._stx_level, 2 )
00267         self.failIf( d.CookedBody().find('<h1') >= 0 )
00268         self.failUnless( d.CookedBody().find('<h2') >= 0 )
00269 
00270     def test_Init(self):
00271         self.REQUEST['BODY']=BASIC_STRUCTUREDTEXT
00272         d = self._makeOne('foo')
00273         d.PUT(self.REQUEST, self.RESPONSE)
00274         self.assertEqual( d.Format(), 'text/plain' )
00275         self.assertEqual( d.Title(), 'My Document' )
00276         self.assertEqual( d.Description(), 'A document by me' )
00277         self.assertEqual( len(d.Contributors()), 3 )
00278         self.failUnless( d.cooked_text.find('<p>') >= 0 )
00279 
00280         d = self._makeOne('foo', text='')
00281         self.REQUEST['BODY']=BASIC_HTML
00282         d.PUT(self.REQUEST, self.RESPONSE)
00283         self.assertEqual( d.Format(), 'text/html' )
00284         self.assertEqual( d.Title(), 'Title in tag' )
00285         self.assertEqual( len(d.Contributors()), 3 )
00286 
00287         d = self._makeOne('foo', text_format='structured-text',
00288                           title='Foodoc')
00289         self.assertEqual( d.text, '' )
00290         self.failIf( d.CookedBody() )
00291         self.assertEqual( d.title, 'Foodoc' )
00292         self.assertEqual( d.Format(), 'text/plain' )
00293 
00294         # Tracker issue 435:  initial text is not cooked.
00295         d = self._makeOne('foo', text_format='structured-text',
00296                           text=STX_NO_HEADERS)
00297         self.assertEqual( d.EditableBody(), STX_NO_HEADERS )
00298         self.failUnless( d.CookedBody() )
00299         self.assertEqual( d.Format(), 'text/plain' )
00300 
00301     def test_STX_NoHeaders( self ):
00302         self.REQUEST['BODY']=STX_NO_HEADERS
00303         d = self._makeOne('foo')
00304         d.editMetadata( title="Plain STX"
00305                        , description="Look, Ma, no headers!"
00306                        , subject=( "plain", "STX" )
00307                        )
00308         self.assertEqual( d.Format(), 'text/html' )
00309         self.assertEqual( d.Title(), 'Plain STX' )
00310         self.assertEqual( d.Description(), 'Look, Ma, no headers!' )
00311         self.assertEqual( len( d.Subject() ), 2 )
00312         self.failUnless( 'plain' in d.Subject() )
00313         self.failUnless( 'STX' in d.Subject() )
00314 
00315         d.PUT(self.REQUEST, self.RESPONSE)
00316 
00317         self.assertEqual( d.Format(), 'text/plain' )
00318         self.assertEqual( d.Title(), 'Plain STX' )
00319         self.assertEqual( d.Description(), 'Look, Ma, no headers!' )
00320         self.assertEqual( len( d.Subject() ), 2 )
00321         self.failUnless( 'plain' in d.Subject() )
00322         self.failUnless( 'STX' in d.Subject() )
00323 
00324     def test_STX_NoHeaders_but_colon( self ):
00325         d = self._makeOne('foo')
00326         d.editMetadata( title="Plain STX"
00327                        , description="Look, Ma, no headers!"
00328                        , subject=( "plain", "STX" )
00329                        )
00330 
00331         d.edit(text_format='structured-text', text=STX_NO_HEADERS_BUT_COLON)
00332         self.assertEqual( d.EditableBody(), STX_NO_HEADERS_BUT_COLON )
00333 
00334     def test_ZMI_edit( self ):
00335         d = self._makeOne('foo')
00336         d.editMetadata( title="Plain STX"
00337                        , description="Look, Ma, no headers!"
00338                        , subject=( "plain", "STX" )
00339                        )
00340 
00341         d.manage_editDocument( text_format='structured-text'
00342                              , text=STX_NO_HEADERS_BUT_COLON)
00343         self.assertEqual( d.EditableBody(), STX_NO_HEADERS_BUT_COLON )
00344 
00345     def test_Format_methods(self):
00346         d = self._makeOne('foo')
00347         d.setFormat('plain')
00348         self.assertEqual( d.text_format, 'plain' )
00349         self.assertEqual( d.Format(), 'text/plain' )
00350         d.setFormat( d.Format() )
00351         self.assertEqual( d.text_format, 'plain' )
00352 
00353         d.setFormat('structured-text')
00354         self.assertEqual( d.text_format, 'structured-text' )
00355         self.assertEqual( d.Format(), 'text/plain' )
00356         d.setFormat( d.Format() )
00357         self.assertEqual( d.text_format, 'structured-text' )
00358 
00359         d.setFormat('html')
00360         self.assertEqual( d.text_format, 'html' )
00361         self.assertEqual( d.Format(), 'text/html' )
00362         d.setFormat( d.Format() )
00363         self.assertEqual( d.text_format, 'html' )
00364 
00365         d.setFormat('foo')
00366         self.assertEqual( d.text_format, 'structured-text' )
00367 
00368     def test_default_format( self ):
00369         d = self._makeOne('foo', text='')
00370 
00371         self.assertEqual( d.Format(), 'text/plain' )
00372         self.assertEqual( d.text_format, 'structured-text' )
00373 
00374 
00375 class DocumentFTPGetTests(RequestTestBase):
00376 
00377     def setUp(self):
00378         RequestTest.setUp(self)
00379         self.site = DummySite('site').__of__(self.root)
00380 
00381     def testHTML( self ):
00382         self.REQUEST['BODY']=BASIC_HTML
00383 
00384         ttool = self.site._setObject( 'portal_types', TypesTool() )
00385         fti = FTIDATA_CMF15[0].copy()
00386         del fti['id']
00387         ttool._setObject( 'Document', FTI('Document', **fti) )
00388 
00389         zpt = self.site._setObject( 'source_html',
00390                                     ZopePageTemplate('source_html') )
00391         dir = abspath( dirname(utils.__file__) )
00392         _file = path_join(dir, 'skins', 'zpt_content', 'source_html.pt')
00393         data = open(_file, 'r').read()
00394         zpt.write(data)
00395 
00396         d = self._makeOne('foo')
00397         d._setPortalTypeName('Document')
00398         d.PUT(self.REQUEST, self.RESPONSE)
00399 
00400         rnlinesplit = compile( r'\r?\n?' )
00401         simple_lines = rnlinesplit.split( BASIC_HTML )
00402         get_lines = rnlinesplit.split( d.manage_FTPget() )
00403 
00404         # strip off headers
00405         meta_pattern = compile( r'meta name="([a-z]*)" '
00406                                  + r'content="([a-z]*)"'
00407                                  )
00408         title_pattern = compile( r'<title>(.*)</title>' )
00409         simple_headers = []
00410         while simple_lines and simple_lines[0] != '<BODY>':
00411             header = simple_lines[0].strip().lower()
00412             match = meta_pattern.search( header )
00413             if match:
00414                 simple_headers.append( match.groups() )
00415             else:
00416                 match = title_pattern.search( header )
00417                 if match:
00418                     simple_headers.append( ( 'title', match.group(1) ) )
00419             simple_lines = simple_lines[1:]
00420 
00421         get_headers = []
00422         while get_lines and get_lines[0] != '<BODY>':
00423             header = get_lines[0].strip().lower()
00424             match = meta_pattern.search( header )
00425             if match:
00426                 get_headers.append( match.groups() )
00427             else:
00428                 match = title_pattern.search( header )
00429                 if match:
00430                     get_headers.append( ( 'title', match.group(1) ) )
00431             get_lines = get_lines[1:]
00432 
00433         self.assertEqual( get_lines, simple_lines )
00434 
00435         self.failUnless( get_headers )
00436         self.failUnless( simple_headers )
00437         self.failUnless( len( get_headers ) >= len( simple_headers ) )
00438 
00439         for header in simple_headers:
00440             self.failUnless( header in get_headers )
00441 
00442         body1 = d.EditableBody()
00443         self.REQUEST['BODY'] = d.manage_FTPget()
00444         d.PUT(self.REQUEST, self.RESPONSE)
00445         self.assertEqual( d.EditableBody(), body1 )
00446 
00447     def testSTX( self ):
00448         self.REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT
00449         d = self._makeOne('foo')
00450         d.PUT(self.REQUEST, self.RESPONSE)
00451 
00452         rnlinesplit = compile( r'\r?\n?' )
00453 
00454         get_text = d.manage_FTPget()
00455         simple_lines = rnlinesplit.split( SIMPLE_STRUCTUREDTEXT )
00456         get_lines = rnlinesplit.split( get_text )
00457 
00458         # strip off headers
00459         simple_headers = []
00460         while simple_lines and simple_lines[0]:
00461             simple_headers.append( simple_lines[0] )
00462             simple_lines = simple_lines[1:]
00463 
00464         get_headers = []
00465         while get_lines and get_lines[0]:
00466             get_headers.append( get_lines[0] )
00467             get_lines = get_lines[1:]
00468 
00469         self.assertEqual( get_lines, simple_lines )
00470 
00471         for header in simple_headers:
00472             self.failUnless( header in get_headers )
00473 
00474 
00475 class DocumentPUTTests(RequestTestBase):
00476 
00477     def test_PUTBasicHTML(self):
00478         self.REQUEST['BODY'] = BASIC_HTML
00479         d = self._makeOne('foo')
00480         r = d.PUT(self.REQUEST, self.RESPONSE)
00481 
00482         self.failUnless( hasattr(d, 'cooked_text') )
00483         self.assertEqual( d.Format(), 'text/html' )
00484         self.assertEqual( d.title, 'Title in tag' )
00485         self.assertEqual( d.text.find('</body>'), -1 )
00486         self.assertEqual( d.Description(), 'Describe me' )
00487         self.assertEqual( len(d.Contributors()), 3 )
00488         self.assertEqual( d.Contributors()[-1],
00489                           'Benotz, Larry J (larry@benotz.stuff)' )
00490         self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ' )
00491         self.assertEqual( r.status, 204 )
00492 
00493         subj = list(d.Subject())
00494         self.assertEqual( len(subj), 4 )
00495         subj.sort()
00496         self.assertEqual( subj, [ 'content management'
00497                                 , 'framework'
00498                                 , 'unit tests'
00499                                 , 'zope'
00500                                 ] )
00501 
00502     def test_PUTSimpleXHTML(self):
00503         self.REQUEST['BODY'] = SIMPLE_XHTML
00504         d = self._makeOne('foo')
00505         r = d.PUT(self.REQUEST, self.RESPONSE)
00506 
00507         self.failUnless( hasattr(d, 'cooked_text') )
00508         self.assertEqual( d.Format(), 'text/html' )
00509         self.assertEqual( d.Description(), 'Describe me' )
00510         self.assertEqual( d.cooked_text, '\n  <h1>Not a lot here</h1>\n ' )
00511         self.assertEqual( r.status, 204 )
00512 
00513     def test_PutStructuredTextWithHTML(self):
00514         self.REQUEST['BODY'] = STX_WITH_HTML
00515         d = self._makeOne('foo')
00516         r = d.PUT(self.REQUEST, self.RESPONSE)
00517 
00518         self.assertEqual( d.Format(), 'text/plain' )
00519         self.assertEqual( r.status, 204 )
00520 
00521     def test_PutStructuredText(self):
00522         self.REQUEST['BODY'] = BASIC_STRUCTUREDTEXT
00523         d = self._makeOne('foo')
00524         r = d.PUT(self.REQUEST, self.RESPONSE)
00525 
00526         self.assertEqual( d.Format(), 'text/plain' )
00527         self.assertEqual( r.status, 204 )
00528 
00529     def test_PutHtmlWithDoctype(self):
00530         html = '%s\n\n  \n   %s' % (DOCTYPE, BASIC_HTML)
00531         self.REQUEST['BODY'] = html
00532         d = self._makeOne('foo')
00533         r = d.PUT(self.REQUEST, self.RESPONSE)
00534 
00535         self.assertEqual( d.Format(), 'text/html' )
00536         self.assertEqual( d.Description(), 'Describe me' )
00537         self.assertEqual( r.status, 204 )
00538 
00539     def test_PutHtmlWithoutMetadata(self):
00540         html = HTML_TEMPLATE % {'title': 'Foo', 'body': 'Bar'}
00541         self.REQUEST['BODY'] = html
00542         d = self._makeOne('foo')
00543         r = d.PUT(self.REQUEST, self.RESPONSE)
00544 
00545         self.assertEqual( d.Title(), 'Foo' )
00546         self.assertEqual( d.Format(), 'text/html' )
00547         self.assertEqual( d.Description(), '' )
00548         self.assertEqual( d.Subject(), () )
00549         self.assertEqual( d.Contributors(), () )
00550         self.assertEqual( d.EffectiveDate(), 'None' )
00551         self.assertEqual( d.ExpirationDate(), 'None' )
00552         self.assertEqual( d.Language(), '' )
00553         self.assertEqual( d.Rights(), '' )
00554         self.assertEqual( r.status, 204 )
00555 
00556 
00557 def test_suite():
00558     return unittest.TestSuite((
00559         unittest.makeSuite(DocumentTests),
00560         unittest.makeSuite(DocumentFTPGetTests),
00561         unittest.makeSuite(DocumentPUTTests),
00562         ))
00563 
00564 if __name__ == '__main__':
00565     unittest.main(defaultTest='test_suite')