Ejemplo n.º 1
0
    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')
Ejemplo n.º 2
0
    def test_PUT_html_with_doctype(self):

        d = NewsItem('foo')
        self.REQUEST['BODY'] = '%s\n%s' % (DOCTYPE, BASIC_HTML)
        d.PUT(self.REQUEST, self.RESPONSE)

        self.assertEqual(d.Description(), 'Describe me')
Ejemplo n.º 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'
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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'
Ejemplo n.º 12
0
 def test_HtmlWithDoctype(self):
     REQUEST = fakeRequest()
     d = NewsItem('foo')
     REQUEST['BODY'] = '%s\n%s' % (DOCTYPE, BASIC_HTML)
     d.PUT(REQUEST, RESPONSE=fakeResponse())
     assert d.Description() == 'Describe me'
Ejemplo n.º 13
0
 def test_EntityInTitle(self):
     REQUEST = fakeRequest()
     REQUEST['BODY'] = ENTITY_IN_TITLE
     d = NewsItem('foo')
     d.PUT(REQUEST, RESPONSE=fakeResponse())
     assert d.title == '&Auuml;rger', "Title '%s' being lost" % (d.title)