Source

crosswiki / crosswiki / tests.py

Full commit
import unittest

from pyramid import testing

class ViewTests(unittest.TestCase):
    def setUp(self):
        self.config = testing.setUp()

    def tearDown(self):
        testing.tearDown()

    def test_my_view(self):
        from .views import my_view
        request = testing.DummyRequest()
        info = my_view(request)
        self.assertEqual(info['project'], 'crosswiki')

class PageTests(unittest.TestCase):
    def _getTarget(self):
        from .models import Page
        return Page
    def _makeOne(self, *args, **kwargs):
        return self._getTarget()(*args, **kwargs)

    def test_html_content(self):
        target = self._makeOne(page_name=u'FrontPage',
            content=u"""\
FrontPage
---------------------

this is FrontPage
""")

        self.assertEqual(target.html_content, '<div class="document" id="frontpage">\n<h1 class="title">FrontPage</h1>\n<p>this is FrontPage</p>\n</div>\n')