changeset 2459:8ae20e588337

Add a test for AttachFile action.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Tue, 17 Jul 2007 22:40:20 +0200
parents 1007128cb089
children 99b6222544c3
files MoinMoin/action/_tests/test_attachfile.py
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/_tests/test_attachfile.py	Tue Jul 17 22:40:20 2007 +0200
@@ -0,0 +1,28 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - tests of AttachFile action
+
+    @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.action.AttachFile import add_attachment, exists
+from MoinMoin.PageEditor import PageEditor
+from MoinMoin._tests.common import gain_superuser_rights
+
+def test_add_attachment(request):
+    """Test if add_attachment() works"""
+
+    gain_superuser_rights(request)
+    pagename = "AutoCreatedSillyPageToTestAttachments"
+    filename = "AutoCreatedSillyAttachment"
+
+    editor = PageEditor(request, pagename)
+    editor.deletePage()
+    editor.saveText("Test text!", 0)
+
+    print "First of all, no exceptions should be raised!"
+    add_attachment(request, pagename, filename, "Test content", True)
+
+    print "The save attachment should actually exist!"
+    assert exists(request, pagename, filename)