예제 #1
0
 def test_BasicHtml(self):
     d = NewsItem('foo', text=BASIC_HTML)
     assert d.Format() == 'text/html', d.Format()
     assert d.title == 'Title in tag'
     assert string.find(d.text, '</body>') == -1
     assert d.Description() == 'Describe me'
     assert len(d.Contributors()) == 2
예제 #2
0
 def test_BasicHtml(self):
     REQUEST = fakeRequest()
     REQUEST['BODY'] = BASIC_HTML
     d = NewsItem('foo')
     d.PUT(REQUEST, RESPONSE=fakeResponse())
     assert d.Format() == 'text/html', d.Format()
     assert d.title == 'Title in tag'
     assert string.find(d.text, '</body>') == -1
     assert d.Description() == 'Describe me'
     assert len(d.Contributors()) == 2
예제 #3
0
 def test_HtmlWithoutNewlines(self):
     REQUEST = fakeRequest()
     d = NewsItem('foo')
     REQUEST['BODY'] = string.join(string.split(BASIC_HTML, '\n'), '')
     d.PUT(REQUEST, RESPONSE=fakeResponse())
     assert d.Format() == 'text/html'
     assert d.Description() == 'Describe me'
예제 #4
0
    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'
예제 #5
0
    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, '')
예제 #6
0
    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, '')
예제 #7
0
    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, '')
예제 #8
0
 def test_UpperedHtml(self):
     d = NewsItem('foo')
     d.edit(text_format='',
            description='bar',
            text=string.upper(BASIC_HTML))
     assert d.Format() == 'text/html'
     assert d.title == 'TITLE IN TAG'
     assert string.find(d.text, '</BODY') == -1
     assert d.Description() == 'DESCRIBE ME'
     assert len(d.Contributors()) == 2
예제 #9
0
 def test_UpperedHtml(self):
     REQUEST = fakeRequest()
     REQUEST['BODY'] = string.upper(BASIC_HTML)
     d = NewsItem('foo')
     d.PUT(REQUEST, RESPONSE=fakeResponse())
     assert d.Format() == 'text/html'
     assert d.title == 'TITLE IN TAG'
     assert string.find(d.text, '</BODY') == -1
     assert d.Description() == 'DESCRIBE ME'
     assert len(d.Contributors()) == 2
예제 #10
0
    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
예제 #11
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
예제 #12
0
    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)
예제 #13
0
    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)
예제 #14
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)
예제 #15
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)
예제 #16
0
    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'
예제 #17
0
 def test_HtmlWithoutNewlines(self):
     d = NewsItem('foo')
     html = string.join(string.split(BASIC_HTML, '\n'), '')
     d.edit(text_format='', description='bar', text=html)
     assert d.Format() == 'text/html'
     assert d.Description() == 'Describe me'
예제 #18
0
 def test_default_format(self):
     d = NewsItem('foo')
     self.assertEqual(d.Format(), 'text/plain')
     self.assertEqual(d.text_format, 'structured-text')