changeset 2397:a10ae31a6133

Test if page save really fails when PreSave event handlers return Abort.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 15 Jul 2007 23:41:14 +0200
parents cf85b6916d17
children f9d087b59fd4 4bc95d828197
files MoinMoin/_tests/test_PageEditor.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_PageEditor.py	Sun Jul 15 23:40:40 2007 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Sun Jul 15 23:41:14 2007 +0200
@@ -169,3 +169,25 @@
         page = Page(self.request, self.dictPage)
         return page.getPagePath(use_underlay=0, check_create=0)
 
+
+def testSave(request):
+    """Test if saveText() is interrupted if PagePreSave event handler returns Abort"""
+
+    def handler(event):
+        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'AutoCreatedMoinMoinTemporaryTestPage'
+    testtext = u'ThisIsSomeStupidTestPageText!!'
+
+    cfg = request.cfg
+    cfg.event_handlers = [handler]
+    
+    editor = PageEditor(request, pagename)
+    editor._write_file = dummy_write
+    editor.saveText(testtext, 0)
+