annotate MoinMoin/request/_tests/test_request.py @ 2892:863060b2cfc5

cleanup http header emission, support list-type headers, add tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 20 Oct 2007 17:51:48 +0200
parents 7d97003c0f9a
children 408b301a5e44
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - MoinMoin.module_tested Tests
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>,
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
6 2007 by MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
10 import py
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
11
2172
c15ec6a2c69e reduce number of failing tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
12 from MoinMoin import config, wikiutil
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13
2892
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
14 from MoinMoin.request import HeadersAlreadySentException
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
15
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
16 class TestNormalizePagename(object):
891
ba1b39629510 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
17
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 def testPageInvalidChars(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 """ request: normalize pagename: remove invalid unicode chars
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 Assume the default setting
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 """
891
ba1b39629510 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
23 test = u'\u0000\u202a\u202b\u202c\u202d\u202e'
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 expected = u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 result = self.request.normalizePagename(test)
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
26 assert result == expected
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 def testNormalizeSlashes(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 """ request: normalize pagename: normalize slashes """
891
ba1b39629510 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
30 cases = (
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 (u'/////', u''),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 (u'/a', u'a'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33 (u'a/', u'a'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 (u'a/////b/////c', u'a/b/c'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 (u'a b/////c d/////e f', u'a b/c d/e f'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 for test, expected in cases:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 result = self.request.normalizePagename(test)
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
39 assert result == expected
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
40
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 def testNormalizeWhitespace(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 """ request: normalize pagename: normalize whitespace """
891
ba1b39629510 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
43 cases = (
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 (u' ', u''),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 (u' a', u'a'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 (u'a ', u'a'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 (u'a b c', u'a b c'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 (u'a b / c d / e f', u'a b/c d/e f'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 # All 30 unicode spaces
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50 (config.chars_spaces, u''),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52 for test, expected in cases:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 result = self.request.normalizePagename(test)
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
54 assert result == expected
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 def testUnderscoreTestCase(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 """ request: normalize pagename: underscore convert to spaces and normalized
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 Underscores should convert to spaces, then spaces should be
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 normalized, order is important!
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 """
891
ba1b39629510 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
62 cases = (
895
eb465f4d2af0 fixed underscore issues in test_request
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
63 (u' ', u''),
eb465f4d2af0 fixed underscore issues in test_request
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
64 (u' a', u'a'),
eb465f4d2af0 fixed underscore issues in test_request
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
65 (u'a ', u'a'),
eb465f4d2af0 fixed underscore issues in test_request
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
66 (u'a b c', u'a b c'),
eb465f4d2af0 fixed underscore issues in test_request
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
67 (u'a b / c d / e f', u'a b/c d/e f'),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
69 for test, expected in cases:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
70 result = self.request.normalizePagename(test)
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
71 assert result == expected
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
72
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
73
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
74 class TestGroupPages(object):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
76 def setup_method(self, method):
2006
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1920
diff changeset
77 self.config = self.TestConfig(page_group_regex=r'.+Group')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
78
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
79 def teardown_method(self, method):
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
80 del self.config
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
81
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
82 def testNormalizeGroupName(self):
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
83 """ request: normalize pagename: restrict groups to alpha numeric Unicode
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2270
diff changeset
84
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
85 Spaces should normalize after invalid chars removed!
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
86 """
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
87 import re
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
88 cases = (
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
89 # current acl chars
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
90 (u'Name,:Group', u'NameGroup'),
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
91 # remove than normalize spaces
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
92 (u'Name ! @ # $ % ^ & * ( ) + Group', u'Name Group'),
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
93 )
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
94 for test, expected in cases:
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
95 # validate we are testing valid group names
2172
c15ec6a2c69e reduce number of failing tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
96 if wikiutil.isGroupPage(self.request, test):
c15ec6a2c69e reduce number of failing tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
97 result = self.request.normalizePagename(test)
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
98 assert result == expected
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
99
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
100
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
101 class TestHTTPDate(object):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
102
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
103 def testRFC1123Date(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
104 """ request: httpDate default rfc1123 """
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
105 assert self.request.httpDate(0) == 'Thu, 01 Jan 1970 00:00:00 GMT'
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
107 def testRFC850Date(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108 """ request: httpDate rfc850 """
2823
7d97003c0f9a tests: convert request tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
109 assert self.request.httpDate(0, rfc='850') == 'Thursday, 01-Jan-70 00:00:00 GMT'
891
ba1b39629510 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
110
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
111
2892
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
112 class TestHTTPHeaders(object):
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
113 std_headers = ['Status: 200 OK', 'Content-type: text/html; charset=UTF-8', ]
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
114
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
115 def setup_method(self, method):
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
116 self.request.sent_headers = False
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
117
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
118 def testAutoAddStdHeaders(self):
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
119 """ test if the usual headers get auto-added if not specified """
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
120 print self.request.sent_headers
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
121 assert self.request.emit_http_headers(testing=True) == self.std_headers
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
122
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
123 def testHeadersOnlyOnce(self):
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
124 """ test if trying to call emit_http_headers multiple times raises an exception """
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
125 print self.request.sent_headers
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
126 self.request.emit_http_headers(testing=True)
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
127 py.test.raises(HeadersAlreadySentException, self.request.emit_http_headers, [], {'testing': True})
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
128
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
129 def testDuplicateHeadersIgnored(self):
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
130 """ test if duplicate headers get ignored """
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
131 print self.request.sent_headers
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
132 headers_in = self.std_headers + ['Status: 500 Server Error']
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
133 headers_expected = self.std_headers
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
134 assert self.request.emit_http_headers(headers_in, testing=True) == headers_expected
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
135
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
136 def testListHeaders(self):
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
137 """ test if header values get merged into a list for headers supporting it """
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
138 print self.request.sent_headers
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
139 headers_in = self.std_headers + ['Vary: aaa', 'vary: bbb']
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
140 headers_expected = self.std_headers + ['Vary: aaa, bbb']
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
141 assert self.request.emit_http_headers(headers_in, testing=True) == headers_expected
863060b2cfc5 cleanup http header emission, support list-type headers, add tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2823
diff changeset
142
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
143 coverage_modules = ['MoinMoin.request']
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
144