changeset 2407:ca02fd95fe59

"Fixed" PageEditor test.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Mon, 16 Jul 2007 12:38:00 +0200
parents 212cd3474046
children c3d3d7b7a048 7c32a0f0d570
files MoinMoin/_tests/test_PageEditor.py
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_PageEditor.py	Mon Jul 16 01:51:34 2007 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Mon Jul 16 12:38:00 2007 +0200
@@ -12,7 +12,7 @@
 
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
-
+from MoinMoin._tests.common import gain_superuser_rights
 
 class TestExpandVars(unittest.TestCase):
     """PageEditor: testing page editor"""
@@ -177,17 +177,23 @@
         from MoinMoin.events import Abort
         return Abort("This is just a test")
 
-    def dummy_write(self, *args, **kwargs):
-        print "PageEditor can't save a page if Abort is returned from PreSave event handlers"
-        assert False
+    pagename = u'AutoCreatedMoinMoinTemporaryTestPageFortestSave'
+    testtext = u'ThisIsSomeStupidTestPageText!'
 
-    pagename = u'AutoCreatedMoinMoinTemporaryTestPage'
-    testtext = u'ThisIsSomeStupidTestPageText!!'
-
+    gain_superuser_rights(request)
     cfg = request.cfg
     cfg.event_handlers = [handler]
 
+    page = Page(request, pagename)
+    if page.exists():
+        deleter = PageEditor(request, pagename)
+        deleter.deletePage()
+        print 'BODY:', deleter.body
+    
     editor = PageEditor(request, pagename)
-    editor._write_file = dummy_write
+    print 'BODY:', editor.body
     editor.saveText(testtext, 0)
-
+    
+    print "PageEditor can't save a page if Abort is returned from PreSave event handlers"
+    page = Page(request, pagename)
+    assert page.body != testtext