annotate MoinMoin/_tests/test_wsgiapp.py @ 4781:cee722c2097c

Groups2009: wikiconfig_groups.py is used for the groups-related configuration instead of altering wikiconfig.py in _tests.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Wed, 03 Jun 2009 12:10:14 +0200
parents f02b3e7dffe6
children 465cb6f5c6d7
rev   line source
4217
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
2 """
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
3 MoinMoin - MoinMoin.wsgiapp Tests
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
4
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
5 @copyright: 2008 MoinMoin:FlorianKrupicka
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
7 """
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
8 from StringIO import StringIO
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
9
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
10 from MoinMoin import wsgiapp
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
11
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
12 DOC_TYPE = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
13
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
14 class TestApplication:
4441
f02b3e7dffe6 fixed wsgiapplication tests
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 4327
diff changeset
15 # self.client is made by conftest
4217
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
16
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
17 # These should exist
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
18 PAGES = ('FrontPage', 'RecentChanges', 'HelpContents', 'FindPage')
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
19 # ... and these should not
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
20 NO_PAGES = ('FooBar', 'TheNone/ExistantPage/', '%33Strange%74Codes')
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
21
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
22 def testWSGIAppExisting(self):
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
23 for page in self.PAGES:
4441
f02b3e7dffe6 fixed wsgiapplication tests
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 4327
diff changeset
24 def _test_(page=page):
4217
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
25 appiter, status, headers = self.client.get('/%s' % page)
4441
f02b3e7dffe6 fixed wsgiapplication tests
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 4327
diff changeset
26 output = ''.join(appiter)
f02b3e7dffe6 fixed wsgiapplication tests
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 4327
diff changeset
27 print output
4217
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
28 assert status[:3] == '200'
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
29 assert ('Content-Type', 'text/html; charset=utf-8') in headers
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
30 for needle in (DOC_TYPE, page):
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
31 assert needle in output
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
32 yield _test_
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
33
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
34 def testWSGIAppAbsent(self):
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
35 for page in self.NO_PAGES:
4441
f02b3e7dffe6 fixed wsgiapplication tests
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 4327
diff changeset
36 def _test_(page=page):
4217
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
37 appiter, status, headers = self.client.get('/%s' % page)
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
38 assert status[:3] == '404'
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
39 output = ''.join(appiter)
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
40 for needle in ('new empty page', 'page template'):
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
41 assert needle in output
b231877df090 Added werkzeug.test.Client for blackbox application testing (headers, status, output)
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
diff changeset
42 yield _test_