changeset 2268:e6792cdb3e83

Page: added some tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 01 Jul 2007 02:19:11 +0200
parents 463f3de3f981
children 9f9a79d5a8d9
files MoinMoin/_tests/test_Page.py
diffstat 1 files changed, 53 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_Page.py	Sun Jul 01 01:23:48 2007 +0200
+++ b/MoinMoin/_tests/test_Page.py	Sun Jul 01 02:19:11 2007 +0200
@@ -2,24 +2,62 @@
 """
     MoinMoin - MoinMoin.Page Tests
 
-    @copyright: 2003-2004 by Juergen Hermann <jh@web.de>
+    @copyright: 2007 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
-import unittest # LEGACY UNITTEST, PLEASE DO NOT IMPORT unittest IN NEW TESTS, PLEASE CONSULT THE py.test DOCS
-from MoinMoin import Page
+import py
 
-class TestExists(unittest.TestCase):
-    """Page: testing wiki page"""
+from MoinMoin.Page import Page
+
+class TestPage:
+    def testMeta(self):
+        page = Page(self.request, u'FrontPage')
+        meta = page.meta
+        for k, v in meta:
+            if k == u'format':
+                assert v == u'wiki'
+            elif k == u'language':
+                assert v == u'en'
+
+    def testBody(self):
+        page = Page(self.request, u'FrontPage')
+        body = page.body
+        assert type(body) is unicode
+        assert 'MoinMoin' in body
+        assert body.endswith('\n')
+        assert '\r' not in body
 
     def testExists(self):
-        """ Page: page.exists() finds existing pages only """
-        tests = (
-            # Page name,                            expected
-            ('FrontPage',                           1),
-            ('OnlyAnIdiotWouldCreateSuchaPage',     0),
-            )
-        for name, expected in tests:
-            pg = Page.Page(self.request, name)
-            self.assertEqual(pg.exists(), expected,
-                             '%s should%s exist' % (name, (' not', '')[expected]))
+        assert Page(self.request, 'FrontPage').exists()
+        assert not Page(self.request, 'ThisPageDoesNotExist').exists()
+        assert not Page(self.request, '').exists()
+
+    def testLastEdit(self):
+        page = Page(self.request, u'FrontPage')
+        last_edit = page.last_edit(self.request)
+        assert 'editor' in last_edit
+        assert 'timestamp' in last_edit
+
+    def testSplitTitle(self):
+        page = Page(self.request, u"FrontPage")
+        assert page.split_title(force=True) == u'Front Page'
+
+    def testGetRevList(self):
+        page = Page(self.request, u"FrontPage")
+        assert page.getRevList() == [1]
+
+    def testGetPageLinks(self):
+        page = Page(self.request, u"FrontPage")
+        assert u'WikiSandBox' in page.getPageLinks(self.request)
+
+
+class TestRootPage:
+    def testPageList(self):
+        rootpage = self.request.rootpage
+        pagelist = rootpage.getPageList()
+        assert len(pagelist) > 100
+        assert u'FrontPage' in pagelist
+        assert u'' not in pagelist
+
+