changeset 2886:dbd445620f9d

test_Attachfile: getFilename checked for creating attachments dir
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 03 Oct 2007 10:47:31 +0200
parents 48a1f6b6b6c5
children aea1aadf2cfb
files MoinMoin/action/_tests/test_attachfile.py
diffstat 1 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/_tests/test_attachfile.py	Wed Oct 03 10:46:10 2007 +0200
+++ b/MoinMoin/action/_tests/test_attachfile.py	Wed Oct 03 10:47:31 2007 +0200
@@ -3,10 +3,11 @@
     MoinMoin - tests of AttachFile action
 
     @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
+                     MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
-
-from MoinMoin.action.AttachFile import add_attachment, exists
+import os
+from MoinMoin.action import AttachFile
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin._tests.common import gain_superuser_rights
 
@@ -22,7 +23,24 @@
     editor.saveText("Test text!", 0)
 
     print "First of all, no exceptions should be raised!"
-    add_attachment(request, pagename, filename, "Test content", True)
+    AttachFile.add_attachment(request, pagename, filename, "Test content", True)
 
     print "The save attachment should actually exist!"
-    assert exists(request, pagename, filename)
+    assert AttachFile.exists(request, pagename, filename)
+
+def test_get_attachment_path_created_on_getFilename(request):
+    """
+    Tests if AttachFile.getFilename creates the attachment dir on requesting
+    """
+    pagename = "ThisPageDoesOnlyExistForThisTest"
+    filename = ""
+    result = os.path.exists(AttachFile.getFilename(request, pagename, filename))
+    expect = True
+
+    # real delete pagename from filesystem
+    import shutil
+    page = PageEditor(request, pagename, do_editor_backup=0)
+    fpath = page.getPagePath(check_create=0)
+    shutil.rmtree(fpath, True)
+
+    assert expect == result