def test_Init(self): self.REQUEST['BODY'] = BASIC_STRUCTUREDTEXT d = self.d d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Format(), 'text/plain') self.assertEqual(d.Title(), 'My Document') self.assertEqual(d.Description(), 'A document by me') self.assertEqual(len(d.Contributors()), 3) self.failUnless(d.cooked_text.find('<p>') >= 0) d = Document('foo', text='') self.REQUEST['BODY'] = BASIC_HTML d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Format(), 'text/html') self.assertEqual(d.Title(), 'Title in tag') self.assertEqual(len(d.Contributors()), 3) d = Document('foo', text_format='structured-text', title='Foodoc') self.assertEqual(d.text, '') self.failIf(d.CookedBody()) self.assertEqual(d.title, 'Foodoc') self.assertEqual(d.Format(), 'text/plain') # Tracker issue 435: initial text is not cooked. d = Document('foo', text_format='structured-text', text=STX_NO_HEADERS) self.assertEqual(d.EditableBody(), STX_NO_HEADERS) self.failUnless(d.CookedBody()) self.assertEqual(d.Format(), 'text/plain')
def test_STX_NoHeaders_but_colon(self): d = Document('foo') d.editMetadata(title="Plain STX", description="Look, Ma, no headers!", subject=("plain", "STX")) d.edit(text_format='structured-text', text=STX_NO_HEADERS_BUT_COLON) self.assertEqual(d.EditableBody(), STX_NO_HEADERS_BUT_COLON)