def test_PUT_entity_in_title(self): self.REQUEST['BODY'] = ENTITY_IN_TITLE d = NewsItem('foo') d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Title(), '&Auuml;rger')
def test_Init(self): d = NewsItem('foo', text=BASIC_STRUCTUREDTEXT) assert d.Format() == 'text/plain' assert d.Title() == 'My NewsItem', d.Title() assert d.Description() == 'A news item by me' assert len(d.Contributors()) == 3 assert string.find(d.cooked_text, '<p>') >= 0 d = NewsItem('foo', text=BASIC_HTML) assert d.Format() == 'text/html' assert d.Title() == 'Title in tag' assert len(d.Contributors()) == 2 d = NewsItem('foo', title='Foodoc') assert d.text == '' assert d.title == 'Foodoc' assert d.Format() == 'text/plain'
def test_Empty_stx(self): d = NewsItem('foo', text_format='structured-text') self.assertEqual(d.Title(), '') self.assertEqual(d.Description(), '') self.assertEqual(d.Format(), 'text/plain') self.assertEqual(d.text_format, 'structured-text') self.assertEqual(d.text, '')
def test_Empty_html(self): d = NewsItem('empty', text_format='html') self.assertEqual(d.Title(), '') self.assertEqual(d.Description(), '') self.assertEqual(d.Format(), 'text/html') self.assertEqual(d.text_format, 'html') self.assertEqual(d.text, '')
def test_Init_with_stx(self): d = NewsItem('foo', text_format='structured-text', title='Foodoc') self.assertEqual(d.Title(), 'Foodoc') self.assertEqual(d.Description(), '') self.assertEqual(d.Format(), 'text/plain') self.assertEqual(d.text_format, 'structured-text') self.assertEqual(d.text, '')
def test_StructuredText(self): d = NewsItem('foo') d.edit(text_format='structured-text', description='bar', text=BASIC_STRUCTUREDTEXT) assert d.Format() == 'text/plain' assert d.Title() == 'My NewsItem' assert d.Description() == 'A news item by me' assert len(d.Contributors()) == 3 assert string.find(d.cooked_text, '<p>') >= 0
def test_StructuredText(self): REQUEST = fakeRequest() REQUEST['BODY'] = BASIC_STRUCTUREDTEXT d = NewsItem('foo') d.PUT(REQUEST, RESPONSE=fakeResponse()) assert d.Format() == 'text/plain' assert d.Title() == 'My NewsItem' assert d.Description() == 'A news item by me' assert len(d.Contributors()) == 3 assert string.find(d.cooked_text, '<p>') >= 0
def test_PUT_structured_text(self): self.REQUEST['BODY'] = BASIC_STRUCTUREDTEXT d = NewsItem('foo') d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Title(), 'My Document') self.assertEqual(d.Description(), 'A document by me') self.assertEqual(d.Format(), 'text/plain') self.assertEqual(d.text_format, 'structured-text') self.assertEqual(len(d.Contributors()), 3) self.failUnless(d.cooked_text.find('<p>') >= 0)
def test_PUT_html_without_newlines(self): d = NewsItem('foo') self.REQUEST['BODY'] = ''.join(BASIC_HTML.split('\n')) d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Title(), 'Title in tag') self.assertEqual(d.Description(), 'Describe me') self.assertEqual(d.Format(), 'text/html') self.assertEqual(d.text_format, 'html') self.assertEqual(d.text.find('</body>'), -1) self.assertEqual(len(d.Contributors()), 3)
def test_PUT_uppered_html(self): self.REQUEST['BODY'] = BASIC_HTML.upper() d = NewsItem('foo') d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Title(), 'TITLE IN TAG') self.assertEqual(d.Description(), 'DESCRIBE ME') self.assertEqual(d.Format(), 'text/html') self.assertEqual(d.text_format, 'html') self.assertEqual(d.text.find('</BODY'), -1) self.assertEqual(len(d.Contributors()), 3)
def test_PUT_basic_html(self): self.REQUEST['BODY'] = BASIC_HTML d = NewsItem('foo') d.PUT(self.REQUEST, self.RESPONSE) self.assertEqual(d.Title(), 'Title in tag') self.assertEqual(d.Description(), 'Describe me') self.assertEqual(d.Format(), 'text/html') self.assertEqual(d.text_format, 'html') self.assertEqual(d.text.find('</body>'), -1) self.assertEqual(len(d.Contributors()), 3)
def test_Init(self): REQUEST = fakeRequest() REQUEST['BODY'] = BASIC_STRUCTUREDTEXT d = NewsItem('foo', text='') d.PUT(REQUEST, RESPONSE=fakeResponse()) assert d.Format() == 'text/plain' assert d.Title() == 'My NewsItem', d.Title() assert d.Description() == 'A news item by me' assert len(d.Contributors()) == 3 assert string.find(d.cooked_text, '<p>') >= 0 d = NewsItem('foo', text='') REQUEST['BODY'] = BASIC_HTML d.PUT(REQUEST, RESPONSE=fakeResponse()) assert d.Format() == 'text/html' assert d.Title() == 'Title in tag' assert len(d.Contributors()) == 2 d = NewsItem('foo', text_format='structured-text', title='Foodoc') assert d.text == '' assert d.title == 'Foodoc' assert d.Format() == 'text/plain'