Back to index

moin  1.9.0~rc2
test_wsgiapp.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 """
00003     MoinMoin - MoinMoin.wsgiapp Tests
00004 
00005     @copyright: 2008 MoinMoin:FlorianKrupicka
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 from StringIO import StringIO
00009 
00010 from MoinMoin import wsgiapp
00011 
00012 DOC_TYPE = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
00013 
00014 class TestApplication:
00015     # self.client is made by conftest
00016 
00017     # These should exist
00018     PAGES = ('FrontPage', 'RecentChanges', 'HelpContents', 'FindPage')
00019     # ... and these should not
00020     NO_PAGES = ('FooBar', 'TheNone/ExistantPage/', '%33Strange%74Codes')
00021 
00022     def testWSGIAppExisting(self):
00023         for page in self.PAGES:
00024             def _test_(page=page):
00025                 appiter, status, headers = self.client.get('/%s' % page)
00026                 output = ''.join(appiter)
00027                 print output
00028                 assert status[:3] == '200'
00029                 assert ('Content-Type', 'text/html; charset=utf-8') in headers
00030                 for needle in (DOC_TYPE, page):
00031                     assert needle in output
00032             yield _test_
00033 
00034     def testWSGIAppAbsent(self):
00035         for page in self.NO_PAGES:
00036             def _test_(page=page):
00037                 appiter, status, headers = self.client.get('/%s' % page)
00038                 assert status[:3] == '404'
00039                 output = ''.join(appiter)
00040                 for needle in ('new empty page', 'page template'):
00041                     assert needle in output
00042             yield _test_