Back to index

moin  1.9.0~rc2
test_Page.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - MoinMoin.Page Tests
00004 
00005     @copyright: 2007 MoinMoin:ThomasWaldmann
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 import py
00010 
00011 from MoinMoin.Page import Page
00012 
00013 class TestPage:
00014     def testMeta(self):
00015         page = Page(self.request, u'FrontPage')
00016         meta = page.meta
00017         for k, v in meta:
00018             if k == u'format':
00019                 assert v == u'wiki'
00020             elif k == u'language':
00021                 assert v == u'en'
00022 
00023     def testBody(self):
00024         page = Page(self.request, u'FrontPage')
00025         body = page.body
00026         assert type(body) is unicode
00027         assert 'MoinMoin' in body
00028         assert body.endswith('\n')
00029         assert '\r' not in body
00030 
00031     def testExists(self):
00032         assert Page(self.request, 'FrontPage').exists()
00033         assert not Page(self.request, 'ThisPageDoesNotExist').exists()
00034         assert not Page(self.request, '').exists()
00035 
00036     def testEditInfoSystemPage(self):
00037         # system pages have no edit-log (and only 1 revision),
00038         # thus edit_info will return None
00039         page = Page(self.request, u'RecentChanges')
00040         edit_info = page.edit_info()
00041         assert edit_info == {}
00042 
00043     def testSplitTitle(self):
00044         page = Page(self.request, u"FrontPage")
00045         assert page.split_title(force=True) == u'Front Page'
00046 
00047     def testGetRevList(self):
00048         page = Page(self.request, u"FrontPage")
00049         assert 1 in page.getRevList()
00050 
00051     def testGetPageLinks(self):
00052         page = Page(self.request, u"FrontPage")
00053         assert u'WikiSandBox' in page.getPageLinks(self.request)
00054 
00055     def testSendPage(self):
00056         page = Page(self.request, u"FrontPage")
00057         import StringIO
00058         out = StringIO.StringIO()
00059         self.request.redirect(out)
00060         page.send_page(msg=u'Done', emit_headers=False)
00061         result = out.getvalue()
00062         self.request.redirect()
00063         del out
00064         assert result.strip().endswith('</html>')
00065         assert result.strip().startswith('<!DOCTYPE HTML PUBLIC')
00066 
00067 class TestRootPage:
00068     def testPageList(self):
00069         rootpage = self.request.rootpage
00070         pagelist = rootpage.getPageList()
00071         assert len(pagelist) > 100
00072         assert u'FrontPage' in pagelist
00073         assert u'' not in pagelist
00074 
00075 
00076 coverage_modules = ['MoinMoin.Page']
00077