changeset 617:7899736d7ede pytest2

added test for wikiutil.file_headers() in _test/test_wikiutil
author pkumar <contactprashantat@gmail.com>
date Mon, 04 Jul 2011 14:13:35 +0530
parents 12057005a39f
children add7c6c78f34
files MoinMoin/_tests/test_wikiutil.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Mon Jul 04 01:36:53 2011 +0530
+++ b/MoinMoin/_tests/test_wikiutil.py	Mon Jul 04 14:13:35 2011 +0530
@@ -240,6 +240,25 @@
     expected = ['#MoinMoin', '']
     assert result == expected
     
+def testfile_headers():
+    test_headers = [
+                #test_file               #content_type
+                ('imagefile.gif',       'image/gif'),     
+                ('testfile.txt',        'text/plain; charset="utf-8"'),
+                ('pdffile.pdf',         'application/pdf'), 
+                ('docfile.doc',         'application/msword'),
+                (None,                  'application/octet-stream')
+                ]
+ 
+    for test_file, content_type in test_headers:
+        result = wikiutil.file_headers(test_file, None, 10)
+        expected = [('Content-Type', content_type), ('Content-Length', '10')]
+        assert result == expected
+
+    # filename is none and content type has a value
+    result = wikiutil.file_headers(None, 'plane/text')
+    expected = [('Content-Type', 'plane/text')]
+    assert result == expected
         
 coverage_modules = ['MoinMoin.wikiutil']