##// END OF EJS Templates
py3: add b'' prefixes in tests/test-hgweb-no-request-uri.t...
Pulkit Goyal -
r39696:a12916cf default
parent child Browse files
Show More
@@ -1,179 +1,179 b''
1 1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
2 2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 3 should be used from d74fc8dec2b4 onward to route the request.
4 4
5 5 $ hg init repo
6 6 $ cd repo
7 7 $ echo foo > bar
8 8 $ hg add bar
9 9 $ hg commit -m "test"
10 10 $ hg tip
11 11 changeset: 0:61c9426e69fe
12 12 tag: tip
13 13 user: test
14 14 date: Thu Jan 01 00:00:00 1970 +0000
15 15 summary: test
16 16
17 17 $ cat > request.py <<EOF
18 18 > from __future__ import absolute_import
19 19 > import os
20 20 > import sys
21 21 > from mercurial.hgweb import (
22 22 > hgweb,
23 23 > hgwebdir,
24 24 > )
25 25 > from mercurial import (
26 26 > util,
27 27 > )
28 28 > stringio = util.stringio
29 29 >
30 30 > errors = stringio()
31 31 > input = stringio()
32 32 >
33 33 > def startrsp(status, headers):
34 34 > print('---- STATUS')
35 35 > print(status)
36 36 > print('---- HEADERS')
37 37 > print([i for i in headers if i[0] != 'ETag'])
38 38 > print('---- DATA')
39 39 > return output.write
40 40 >
41 41 > env = {
42 42 > 'wsgi.version': (1, 0),
43 43 > 'wsgi.url_scheme': 'http',
44 44 > 'wsgi.errors': errors,
45 45 > 'wsgi.input': input,
46 46 > 'wsgi.multithread': False,
47 47 > 'wsgi.multiprocess': False,
48 48 > 'wsgi.run_once': False,
49 49 > 'REQUEST_METHOD': 'GET',
50 50 > 'SCRIPT_NAME': '',
51 51 > 'SERVER_NAME': '$LOCALIP',
52 52 > 'SERVER_PORT': os.environ['HGPORT'],
53 53 > 'SERVER_PROTOCOL': 'HTTP/1.0'
54 54 > }
55 55 >
56 56 > def process(app):
57 57 > content = app(env, startrsp)
58 58 > sys.stdout.write(output.getvalue())
59 59 > sys.stdout.write(''.join(content))
60 60 > getattr(content, 'close', lambda : None)()
61 61 > print('---- ERRORS')
62 62 > print(errors.getvalue())
63 63 >
64 64 > output = stringio()
65 65 > env['PATH_INFO'] = '/'
66 66 > env['QUERY_STRING'] = 'style=atom'
67 > process(hgweb('.', name = 'repo'))
67 > process(hgweb(b'.', name = b'repo'))
68 68 >
69 69 > output = stringio()
70 70 > env['PATH_INFO'] = '/file/tip/'
71 71 > env['QUERY_STRING'] = 'style=raw'
72 > process(hgweb('.', name = 'repo'))
72 > process(hgweb(b'.', name = b'repo'))
73 73 >
74 74 > output = stringio()
75 75 > env['PATH_INFO'] = '/'
76 76 > env['QUERY_STRING'] = 'style=raw'
77 > process(hgwebdir({'repo': '.'}))
77 > process(hgwebdir({'repo': b'.'}))
78 78 >
79 79 > output = stringio()
80 80 > env['PATH_INFO'] = '/repo/file/tip/'
81 81 > env['QUERY_STRING'] = 'style=raw'
82 > process(hgwebdir({'repo': '.'}))
82 > process(hgwebdir({'repo': b'.'}))
83 83 > EOF
84 84 $ $PYTHON request.py
85 85 ---- STATUS
86 86 200 Script output follows
87 87 ---- HEADERS
88 88 [('Content-Type', 'application/atom+xml; charset=ascii')]
89 89 ---- DATA
90 90 <?xml version="1.0" encoding="ascii"?>
91 91 <feed xmlns="http://www.w3.org/2005/Atom">
92 92 <!-- Changelog -->
93 93 <id>http://$LOCALIP:$HGPORT/</id> (glob)
94 94 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
95 95 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
96 96 <title>repo Changelog</title>
97 97 <updated>1970-01-01T00:00:00+00:00</updated>
98 98
99 99 <entry>
100 100 <title>[default] test</title>
101 101 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
102 102 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
103 103 <author>
104 104 <name>test</name>
105 105 <email>&#116;&#101;&#115;&#116;</email>
106 106 </author>
107 107 <updated>1970-01-01T00:00:00+00:00</updated>
108 108 <published>1970-01-01T00:00:00+00:00</published>
109 109 <content type="xhtml">
110 110 <table xmlns="http://www.w3.org/1999/xhtml">
111 111 <tr>
112 112 <th style="text-align:left;">changeset</th>
113 113 <td>61c9426e69fe</td>
114 114 </tr>
115 115 <tr>
116 116 <th style="text-align:left;">branch</th>
117 117 <td>default</td>
118 118 </tr>
119 119 <tr>
120 120 <th style="text-align:left;">bookmark</th>
121 121 <td></td>
122 122 </tr>
123 123 <tr>
124 124 <th style="text-align:left;">tag</th>
125 125 <td>tip</td>
126 126 </tr>
127 127 <tr>
128 128 <th style="text-align:left;">user</th>
129 129 <td>&#116;&#101;&#115;&#116;</td>
130 130 </tr>
131 131 <tr>
132 132 <th style="text-align:left;vertical-align:top;">description</th>
133 133 <td>test</td>
134 134 </tr>
135 135 <tr>
136 136 <th style="text-align:left;vertical-align:top;">files</th>
137 137 <td>bar<br /></td>
138 138 </tr>
139 139 </table>
140 140 </content>
141 141 </entry>
142 142
143 143 </feed>
144 144 ---- ERRORS
145 145
146 146 ---- STATUS
147 147 200 Script output follows
148 148 ---- HEADERS
149 149 [('Content-Type', 'text/plain; charset=ascii')]
150 150 ---- DATA
151 151
152 152 -rw-r--r-- 4 bar
153 153
154 154
155 155 ---- ERRORS
156 156
157 157 ---- STATUS
158 158 200 Script output follows
159 159 ---- HEADERS
160 160 [('Content-Type', 'text/plain; charset=ascii')]
161 161 ---- DATA
162 162
163 163 /repo/
164 164
165 165 ---- ERRORS
166 166
167 167 ---- STATUS
168 168 200 Script output follows
169 169 ---- HEADERS
170 170 [('Content-Type', 'text/plain; charset=ascii')]
171 171 ---- DATA
172 172
173 173 -rw-r--r-- 4 bar
174 174
175 175
176 176 ---- ERRORS
177 177
178 178
179 179 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now