Ejemplo n.º 1
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.º 2
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.º 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):
     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
Ejemplo n.º 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, '')
Ejemplo n.º 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, '')
Ejemplo n.º 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, '')
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
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.º 12
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
Ejemplo n.º 13
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.º 14
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.º 15
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.º 16
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.º 17
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.º 18
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.º 19
0
 def test_HtmlWithDoctype(self):
     d = NewsItem('foo')
     html = '%s\n%s' % (DOCTYPE, BASIC_HTML)
     d.edit(text_format='', description='bar', text=html)
     assert d.Description() == 'Describe me'
Ejemplo n.º 20
0
 def test_EntityInTitle(self):
     d = NewsItem('foo')
     d.edit(text_format='html', description='bar', text=ENTITY_IN_TITLE)
     assert d.title == '&Auuml;rger', "Title '%s' being lost" % (
         d.title )
Ejemplo n.º 21
0
    def _makeOne(self, id, *args, **kw):
        from Products.CMFDefault.NewsItem import NewsItem

        return NewsItem(id, *args, **kw)
Ejemplo n.º 22
0
    def _makeOne(self, id, *args, **kw):
        from Products.CMFDefault.NewsItem import NewsItem

        # NullResource.PUT calls the PUT method on the bare object!
        return NewsItem(id, *args, **kw)
Ejemplo n.º 23
0
 def _makeOne(self, id, *args, **kw):
     return self.site._setObject( id, NewsItem(id, *args, **kw) )
Ejemplo n.º 24
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'
Ejemplo n.º 25
0
 def test_EntityInTitle(self):
     d = NewsItem('foo')
     d.edit(text_format='html', description='bar', text=ENTITY_IN_TITLE)
     assert d.title == '&Auuml;rger', "Title '%s' being lost" % (d.title)
Ejemplo n.º 26
0
 def test_HtmlWithDoctype(self):
     d = NewsItem('foo')
     html = '%s\n%s' % (DOCTYPE, BASIC_HTML)
     d.edit(text_format='', description='bar', text=html)
     assert d.Description() == 'Describe me'
Ejemplo n.º 27
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.º 28
0
 def test_default_format(self):
     d = NewsItem('foo')
     self.assertEqual(d.Format(), 'text/plain')
     self.assertEqual(d.text_format, 'structured-text')
Ejemplo n.º 29
0
 def test_Empty(self):
     d = NewsItem('foo')
     assert d.title == ''
     assert d.description == ''
     assert d.text == ''
     assert d.text_format == 'structured-text'
Ejemplo n.º 30
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'
Ejemplo n.º 31
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)
Ejemplo n.º 32
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'
Ejemplo n.º 33
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'