[Zope3-checkins] CVS: zopeproducts/zwiki/renderer/tests - test_plaintext.py:1.1 test_rest.py:1.1 test_stx.py:1.1
Stephan Richter
srichter@cbu.edu
Sat, 12 Apr 2003 19:05:36 -0400
Update of /cvs-repository/zopeproducts/zwiki/renderer/tests
In directory cvs.zope.org:/tmp/cvs-serv13171/renderer/tests
Added Files:
test_plaintext.py test_rest.py test_stx.py
Log Message:
- Finished a bunch of promised tests. Except for Views everything is tested
now.
- Reworked the source type registry a bit to be more flexible. Now the
actual implementation of a source type interface is also registered. I
moved the createComment() method into the source class, since this is
where it belongs. We only want one createComment() method for each source
and not for each renderer.
=== Added File zopeproducts/zwiki/renderer/tests/test_plaintext.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Plain Text Tests - PlainText Source, HTML Renderer
$Id: test_plaintext.py,v 1.1 2003/04/12 23:05:35 srichter Exp $
"""
import unittest
from zope.publisher.browser import TestRequest
from zopeproducts.zwiki.interfaces import IPlainTextSource, IHTMLRenderer
from zopeproducts.zwiki.renderer.plaintext import \
PlainTextSource, PlainTextToHTMLRenderer
class PlainTextTest(unittest.TestCase):
def setUp(self):
self._source = PlainTextSource(u'This is source.')
def test_Interface(self):
self.failUnless(IPlainTextSource.isImplementedBy(self._source))
def test_createComment(self):
self.assertEqual(comment,
self._source.createComment('This is a Comment.', 2,
'srichter',
'04/12/2003 12:00:00'))
self.assertEqual(first_comment,
self._source.createComment('This is a Comment.', 1,
'srichter',
'04/12/2003 12:00:00'))
class HTMLRendererTest(unittest.TestCase):
def setUp(self):
self._source = PlainTextSource(u'This is source.\n')
self._renderer = PlainTextToHTMLRenderer(self._source, TestRequest())
def test_Interface(self):
self.failUnless(IHTMLRenderer.isImplementedBy(self._renderer))
def test_render(self):
self.assertEqual('This is source.<br/>\n', self._renderer.render(None))
comment = self._source.createComment('This is a Comment.', 1,
'srichter',
'04/12/2003 12:00:00')
self._renderer.context = PlainTextSource(self._source+comment)
self.assertEqual(rendered_source_comment, self._renderer.render(None))
comment = '''
Comment #2 by srichter (04/12/2003 12:00:00)
This is a Comment.'''
first_comment = '''
----------
Comment #1 by srichter (04/12/2003 12:00:00)
This is a Comment.'''
rendered_source_comment = '''This is source.<br/>
<br/>
<hr class="comments" size="1" NOSHADE>
<br/>
Comment #1 by srichter (04/12/2003 12:00:00)<br/>
This is a Comment.'''
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(PlainTextTest),
unittest.makeSuite(HTMLRendererTest),
))
if __name__ == '__main__':
unittest.main()
=== Added File zopeproducts/zwiki/renderer/tests/test_rest.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Structured Text Tests - StructuredText Source, HTML Renderer
$Id: test_rest.py,v 1.1 2003/04/12 23:05:35 srichter Exp $
"""
import unittest
from zope.publisher.browser import TestRequest
from zopeproducts.zwiki.interfaces import IReStructuredTextSource, IHTMLRenderer
from zopeproducts.zwiki.renderer.rest import \
ReStructuredTextSource, ReStructuredTextToHTMLRenderer
class StructuredTextTest(unittest.TestCase):
def setUp(self):
self._source = ReStructuredTextSource(u'This\n is source.')
def test_Interface(self):
self.failUnless(IReStructuredTextSource.isImplementedBy(self._source))
def test_createComment(self):
self.assertEqual(comment,
self._source.createComment('This is a Comment.', 2,
'srichter',
'04/12/2003 12:00:00'))
self.assertEqual(first_comment,
self._source.createComment('This is a Comment.', 1,
'srichter',
'04/12/2003 12:00:00'))
class HTMLRendererTest(unittest.TestCase):
def setUp(self):
self._source = ReStructuredTextSource(u'This is source.\n')
self._renderer = ReStructuredTextToHTMLRenderer(self._source,
TestRequest())
def test_Interface(self):
self.failUnless(IHTMLRenderer.isImplementedBy(self._renderer))
def test_render(self):
self.assertEqual('<div class="document">\nThis is source.</div>\n',
self._renderer.render(None))
comment = self._source.createComment('This is a Comment.', 1,
'srichter',
'04/12/2003 12:00:00')
self._renderer.context = ReStructuredTextSource(self._source+comment)
self.assertEqual(rendered_source_comment, self._renderer.render(None))
comment = '''
Comment #2 by **srichter** (04/12/2003 12:00:00)
This is a Comment.'''
first_comment = '''
----------
Comment #1 by **srichter** (04/12/2003 12:00:00)
This is a Comment.'''
rendered_source_comment = '''<div class="document">\n<p>This is source.</p>
<hr />
<p>Comment #1 by <strong>srichter</strong> (04/12/2003 12:00:00)</p>
<p>This is a Comment.</p>
</div>
'''
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ReStructuredTextTest),
unittest.makeSuite(HTMLRendererTest),
))
if __name__ == '__main__':
unittest.main()
=== Added File zopeproducts/zwiki/renderer/tests/test_stx.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Structured Text Tests - StructuredText Source, HTML Renderer
$Id: test_stx.py,v 1.1 2003/04/12 23:05:35 srichter Exp $
"""
import unittest
from zope.publisher.browser import TestRequest
from zopeproducts.zwiki.interfaces import IStructuredTextSource, IHTMLRenderer
from zopeproducts.zwiki.renderer.stx import \
StructuredTextSource, StructuredTextToHTMLRenderer
class StructuredTextTest(unittest.TestCase):
def setUp(self):
self._source = StructuredTextSource(u'This\n is source.')
def test_Interface(self):
self.failUnless(IStructuredTextSource.isImplementedBy(self._source))
def test_createComment(self):
self.assertEqual(comment,
self._source.createComment('This is a Comment.', 2,
'srichter',
'04/12/2003 12:00:00'))
self.assertEqual(first_comment,
self._source.createComment('This is a Comment.', 1,
'srichter',
'04/12/2003 12:00:00'))
class HTMLRendererTest(unittest.TestCase):
def setUp(self):
self._source = StructuredTextSource(u'This is source.\n')
self._renderer = StructuredTextToHTMLRenderer(self._source,
TestRequest())
def test_Interface(self):
self.failUnless(IHTMLRenderer.isImplementedBy(self._renderer))
def test_render(self):
self.assertEqual('<p>This is source.</p>\n',
self._renderer.render(None))
comment = self._source.createComment('This is a Comment.', 1,
'srichter',
'04/12/2003 12:00:00')
self._renderer.context = StructuredTextSource(self._source+comment)
self.assertEqual(rendered_source_comment, self._renderer.render(None))
comment = '''
Comment #2 by **srichter** (04/12/2003 12:00:00)
This is a Comment.'''
first_comment = '''
----------
Comment #1 by **srichter** (04/12/2003 12:00:00)
This is a Comment.'''
rendered_source_comment = '''<p>This is source.</p>
<hr class="comments" size="1" NOSHADE>
<p>Comment #1 by <strong>srichter</strong> (04/12/2003 12:00:00)</p>
<p>This is a Comment.</p>
'''
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(StructuredTextTest),
unittest.makeSuite(HTMLRendererTest),
))
if __name__ == '__main__':
unittest.main()