changeset 3695:e3b4ae470e86

test_attachfile: tests add_attachment with a mimetype file
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 09 Jun 2008 20:14:14 +0200
parents 56e6073b2e23
children 207ae45bab18
files MoinMoin/action/_tests/test_attachfile.py
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/_tests/test_attachfile.py	Mon Jun 09 12:59:06 2008 +0200
+++ b/MoinMoin/action/_tests/test_attachfile.py	Mon Jun 09 20:14:14 2008 +0200
@@ -27,6 +27,29 @@
 
     assert exists
 
+def test_add_attachment_mimetype(request):
+    """Test if add_attachment() with small mimetype file works"""
+
+    become_trusted(request)
+    pagename = "AutoCreatedSillyPageToTestAttachments"
+    filename = "AutoCreatedSillyAttachment.png"
+
+    create_page(request, pagename, u"FooBar!")
+
+    import base64
+    imageEncodeText = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAMCAIAAADkharWAAAAD0lEQVQokWNgGAWjgDoAAAJMAAFOlIxNAAAAAElFTkSuQmCC"
+    filecontent = base64.decodestring(imageEncodeText)
+
+    AttachFile.add_attachment(request, pagename, filename, filecontent, True)
+    exists = AttachFile.exists(request, pagename, filename)
+    path = AttachFile.getAttachDir(request, pagename)
+    imagef = os.path.join(path, filename)
+    file_size = os.path.getsize(imagef)
+
+    nuke_page(request, pagename)
+
+    assert exists and file_size == 72
+
 def test_get_attachment_path_created_on_getFilename(request):
     """
     Tests if AttachFile.getFilename creates the attachment dir on requesting