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