Example #1
0
    def test_StructuredText(self):
        d = Document('foo')
        assert hasattr(d, 'cooked_text')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        
        assert d.Format() == 'text/plain'
        assert d.Title() == 'My Document'
        assert d.Description() == 'A document by me'
        assert len(d.Contributors()) == 3
        assert string.find(d.cooked_text, '<p>') >= 0
        assert string.find(d.CookedBody(), '<h1') >= 0

        # Make sure extra HTML is NOT found
        assert string.find(d.cooked_text, '<title>') == -1, d.cooked_text
        assert string.find(d.cooked_text, '<body>') == -1, d.cooked_text

        # test subject/keyword headers
        subj = list(d.Subject())
        assert len(subj) == 4
        subj.sort()
        assert subj == [
            'content management',
            'framework',
            'unit tests',
            'zope'
            ]
Example #2
0
    def test_StructuredText(self):
        d = Document('foo')
        assert hasattr(d, 'cooked_text')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        
        assert d.Format() == 'text/plain'
        assert d.Title() == 'My Document'
        assert d.Description() == 'A document by me'
        assert len(d.Contributors()) == 3
        assert string.find(d.cooked_text, '<p>') >= 0

        # Make sure extra HTML is NOT found
        assert string.find(d.cooked_text, '<title>') == -1, d.cooked_text
        assert string.find(d.cooked_text, '<body>') == -1, d.cooked_text

        # test subject/keyword headers
        subj = list(d.Subject())
        assert len(subj) == 4
        subj.sort()
        assert subj == [
            'content management',
            'framework',
            'unit tests',
            'zope'
            ]
Example #3
0
 def edit(self, text, description=None, text_format=None):
     """Edit the News Item.
     """
     if text_format is None:
         text_format = getattr(self, 'text_format', 'structured-text')
     if description is not None:
         self.setDescription(description)
     Document.edit(self, text_format, text)
Example #4
0
 def test_UpperedHtml(self):
     d = Document('foo')
     d.edit(text_format='', 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()) == 3
Example #5
0
    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)
Example #6
0
 def test_UpperedHtml(self):
     d = Document('foo')
     d.edit(text_format='', 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()) == 3
Example #7
0
 def edit( self, text, description=None, text_format=None ):
     """Edit the News Item.
     """
     if text_format is None:
         text_format = getattr(self, 'text_format', 'structured-text')
     if description is not None:
         self.setDescription( description )
     Document.edit( self, text_format, text )
Example #8
0
    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 )
Example #9
0
    def test_StructuredText(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)

        assert d.Format() == 'text/plain'
        assert d.Title() == 'My Document'
        assert d.Description() == 'A document by me'
        assert len(d.Contributors()) == 3
        assert string.find(d.cooked_text, '<p>') >= 0
Example #10
0
 def test_StructuredText(self):
     d = Document('foo')
     d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
     
     assert d.Format() == 'text/plain'
     assert d.Title() == 'My Document'
     assert d.Description() == 'A document by me'
     assert len(d.Contributors()) == 3
     assert string.find(d.cooked_text, '<p>') >= 0
Example #11
0
 def test_BigHtml(self):
     d = Document('foo')
     s = []
     looper = '<li> number %s</li>'
     for i in range(12000): s.append(looper % i)
     body = '<ul>\n%s\n</ul>' % string.join(s, '\n')
     html = HTML_TEMPLATE % {'title': 'big document',
                             'body': body}
     d.edit(text_format=None, text=html)
     assert d.CookedBody() == body
Example #12
0
 def test_BigHtml(self):
     d = Document('foo')
     s = []
     looper = '<li> number %s</li>'
     for i in range(12000):
         s.append(looper % i)
     body = '<ul>\n%s\n</ul>' % string.join(s, '\n')
     html = HTML_TEMPLATE % {'title': 'big document', 'body': body}
     d.edit(text_format=None, text=html)
     assert d.CookedBody() == body
Example #13
0
 def test_BigHtml_via_upload(self):
     d = Document('foo')
     s = []
     looper = '<li> number %s</li>'
     for i in range(12000): s.append(looper % i)
     body = '<ul>\n%s\n</ul>' % string.join(s, '\n')
     html = HTML_TEMPLATE % {'title': 'big document',
                             'body': body}
     from StringIO import StringIO
     file = StringIO( html )
     d.edit(text_format='html', text='', file=file)
     self.assertEqual( d.CookedBody(), body )
Example #14
0
 def test_BigHtml_via_upload(self):
     d = Document('foo')
     s = []
     looper = '<li> number %s</li>'
     for i in range(12000):
         s.append(looper % i)
     body = '<ul>\n%s\n</ul>' % string.join(s, '\n')
     html = HTML_TEMPLATE % {'title': 'big document', 'body': body}
     from StringIO import StringIO
     file = StringIO(html)
     d.edit(text_format='html', text='', file=file)
     assert d.CookedBody() == body
 def edit(self,   
         title='',
         position='',
         topic='',
         description='',
         source='',
         url='',
         text='',
         text_format='',
         file='',
         ):
     """ Edit article properties """     
     Document.edit(self, text_format, text, file)
     self.editMetadata(title=title, description=description)
     self.position=position
     self.topic=topic
     self.source = source
     self.url = string.split(url,'\n')
Example #16
0
    def test_STX_NoHeaders(self):
        d = Document('foo')
        d._editMetadata(title="Plain STX",
                        description="Look, Ma, no headers!",
                        subject=("plain", "STX"))
        assert d.Format() == 'text/html'
        assert d.Title() == 'Plain STX'
        assert d.Description() == 'Look, Ma, no headers!'
        assert len(d.Subject()) == 2
        assert 'plain' in d.Subject()
        assert 'STX' in d.Subject()

        d.edit(text_format='structured-text', text=STX_NO_HEADERS)

        assert d.Format() == 'text/plain'
        assert d.Title() == 'Plain STX'
        assert d.Description() == 'Look, Ma, no headers!'
        assert len(d.Subject()) == 2
        assert 'plain' in d.Subject()
        assert 'STX' in d.Subject()
Example #17
0
    def test_STX_NoHeaders( self ):
        d = Document('foo')
        d._editMetadata( title="Plain STX"
                       , description="Look, Ma, no headers!"
                       , subject=( "plain", "STX" )
                       )
        assert d.Format() == 'text/html'
        assert d.Title() == 'Plain STX'
        assert d.Description() == 'Look, Ma, no headers!'
        assert len( d.Subject() ) == 2
        assert 'plain' in d.Subject()
        assert 'STX' in d.Subject()

        d.edit(text_format='structured-text', text=STX_NO_HEADERS)
        
        assert d.Format() == 'text/plain'
        assert d.Title() == 'Plain STX'
        assert d.Description() == 'Look, Ma, no headers!'
        assert len( d.Subject() ) == 2
        assert 'plain' in d.Subject()
        assert 'STX' in d.Subject()
Example #18
0
    def test_STX_Levels(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        assert d._stx_level == 1

        ct = d.CookedBody()
        assert string.find(d.CookedBody(), '<h1') >= 0
        assert d._stx_level == 1

        ct = d.CookedBody(stx_level=2)
        assert not (string.find(ct, '<h1') >= 0)
        assert string.find(ct, '<h2') >= 0
        assert d._stx_level == 1

        ct = d.CookedBody(stx_level=2, setlevel=1)
        assert not (string.find(ct, '<h1') >= 0)
        assert string.find(ct, '<h2') >= 0
        assert d._stx_level == 2

        ct = d.CookedBody()
        assert d._stx_level == 2
        assert not (string.find(d.CookedBody(), '<h1') >= 0)
        assert string.find(d.CookedBody(), '<h2') >= 0
Example #19
0
    def test_STX_Levels(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        assert d._stx_level == 1

        ct = d.CookedBody()
        assert string.find(d.CookedBody(), '<h1') >= 0
        assert d._stx_level == 1

        ct = d.CookedBody(stx_level=2)
        assert not (string.find(ct, '<h1') >= 0)
        assert string.find(ct, '<h2') >= 0
        assert d._stx_level == 1

        ct = d.CookedBody(stx_level=2, setlevel=1)
        assert not (string.find(ct, '<h1') >= 0)
        assert string.find(ct, '<h2') >= 0
        assert d._stx_level == 2

        ct = d.CookedBody()
        assert d._stx_level == 2
        assert not (string.find(d.CookedBody(), '<h1') >= 0)
        assert string.find(d.CookedBody(), '<h2') >= 0
Example #20
0
    def test_STX_Levels(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        self.assertEqual( d._stx_level, 1 )

        ct = d.CookedBody()
        self.failUnless( string.find(d.CookedBody(), '<h1') >= 0 )
        self.assertEqual( d._stx_level, 1 )

        ct = d.CookedBody(stx_level=2)
        self.failIf( (string.find(ct, '<h1') >= 0) )
        self.failUnless( string.find(ct, '<h2') >= 0 )
        self.assertEqual( d._stx_level, 1 )

        ct = d.CookedBody(stx_level=2, setlevel=1)
        self.failIf( (string.find(ct, '<h1') >= 0) )
        self.failUnless( string.find(ct, '<h2') >= 0 )
        self.assertEqual( d._stx_level, 2 )

        ct = d.CookedBody()
        self.assertEqual( d._stx_level, 2 )
        self.failIf( (string.find(d.CookedBody(), '<h1') >= 0) )
        self.failUnless( string.find(d.CookedBody(), '<h2') >= 0 )
Example #21
0
    def test_STX_Levels(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        self.assertEqual(d._stx_level, 1)

        ct = d.CookedBody()
        self.failUnless(string.find(d.CookedBody(), '<h1') >= 0)
        self.assertEqual(d._stx_level, 1)

        ct = d.CookedBody(stx_level=2)
        self.failIf((string.find(ct, '<h1') >= 0))
        self.failUnless(string.find(ct, '<h2') >= 0)
        self.assertEqual(d._stx_level, 1)

        ct = d.CookedBody(stx_level=2, setlevel=1)
        self.failIf((string.find(ct, '<h1') >= 0))
        self.failUnless(string.find(ct, '<h2') >= 0)
        self.assertEqual(d._stx_level, 2)

        ct = d.CookedBody()
        self.assertEqual(d._stx_level, 2)
        self.failIf((string.find(d.CookedBody(), '<h1') >= 0))
        self.failUnless(string.find(d.CookedBody(), '<h2') >= 0)
Example #22
0
    def test_EditStructuredTextWithHTML(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=STX_WITH_HTML)

        self.assertEqual(d.Format(), 'text/plain')
Example #23
0
    def test_EditStructuredTextWithHTML(self):
        d = Document('foo')
        d.edit(text_format=None, text=STX_WITH_HTML)

        assert d.Format() == 'text/plain', "%s != %s" % (d.Format(),
                                                         'text/plain')
Example #24
0
 def test_HtmlWithoutNewlines(self):
     d = Document('foo')
     html = string.join(string.split(BASIC_HTML, '\n'), '')
     d.edit(text_format='', text=html)
     assert d.Format() == 'text/html'
     assert d.Description() == 'Describe me'
Example #25
0
 def test_HtmlWithDoctype(self):
     d = Document('foo')
     html = '%s\n%s' % (DOCTYPE, BASIC_HTML)
     d.edit(text_format='', text=html)
     assert d.Description() == 'Describe me'
Example #26
0
 def test_EntityInTitle(self):
     d = Document('foo')
     d.edit(text_format='html', text=ENTITY_IN_TITLE)
     assert d.title == '&Auuml;rger', "Title '%s' being lost" % (d.title)
Example #27
0
 def test_EditStructuredTextWithHTML(self):
     d = Document('foo')
     d.edit(text_format='structured-text', text=STX_WITH_HTML)
     
     self.assertEqual( d.Format(), 'text/plain' )
Example #28
0
 def test_EditStructuredTextWithHTML(self):
     d = Document('foo')
     d.edit(text_format=None, text=STX_WITH_HTML)
     
     assert d.Format() == 'text/plain', "%s != %s" % (
         d.Format(), 'text/plain')
Example #29
0
 def test_HtmlWithoutNewlines(self):
     d = Document('foo')
     html = string.join(string.split(BASIC_HTML, '\n'), '')
     d.edit(text_format='', text=html)
     assert d.Format() == 'text/html'
     assert d.Description() == 'Describe me'
Example #30
0
 def test_HtmlWithDoctype(self):
     d = Document('foo')
     html = '%s\n%s' % (DOCTYPE, BASIC_HTML)
     d.edit(text_format='', text=html)
     assert d.Description() == 'Describe me'
Example #31
0
 def test_EntityInTitle(self):
     d = Document('foo')
     d.edit(text_format='html', text=ENTITY_IN_TITLE)
     assert d.title == '&Auuml;rger', "Title '%s' being lost" % (
         d.title )