##// END OF EJS Templates
py3: use absolute_import in test-hgweb-no-path-info.t
timeless -
r28857:9f67cf7c default
parent child Browse files
Show More
@@ -1,138 +1,143 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 > from mercurial.hgweb import hgweb, hgwebdir
18 > from __future__ import absolute_import
19 > import os
20 > import sys
19 21 > from StringIO import StringIO
20 > import os, sys
22 > from mercurial.hgweb import (
23 > hgweb,
24 > hgwebdir,
25 > )
21 26 >
22 27 > errors = StringIO()
23 28 > input = StringIO()
24 29 >
25 30 > def startrsp(status, headers):
26 31 > print '---- STATUS'
27 32 > print status
28 33 > print '---- HEADERS'
29 34 > print [i for i in headers if i[0] != 'ETag']
30 35 > print '---- DATA'
31 36 > return output.write
32 37 >
33 38 > env = {
34 39 > 'wsgi.version': (1, 0),
35 40 > 'wsgi.url_scheme': 'http',
36 41 > 'wsgi.errors': errors,
37 42 > 'wsgi.input': input,
38 43 > 'wsgi.multithread': False,
39 44 > 'wsgi.multiprocess': False,
40 45 > 'wsgi.run_once': False,
41 46 > 'REQUEST_METHOD': 'GET',
42 47 > 'PATH_INFO': '/',
43 48 > 'SCRIPT_NAME': '',
44 49 > 'SERVER_NAME': '127.0.0.1',
45 50 > 'SERVER_PORT': os.environ['HGPORT'],
46 51 > 'SERVER_PROTOCOL': 'HTTP/1.0'
47 52 > }
48 53 >
49 54 > def process(app):
50 55 > content = app(env, startrsp)
51 56 > sys.stdout.write(output.getvalue())
52 57 > sys.stdout.write(''.join(content))
53 58 > getattr(content, 'close', lambda : None)()
54 59 > print '---- ERRORS'
55 60 > print errors.getvalue()
56 61 >
57 62 > output = StringIO()
58 63 > env['QUERY_STRING'] = 'style=atom'
59 64 > process(hgweb('.', name='repo'))
60 65 >
61 66 > output = StringIO()
62 67 > env['QUERY_STRING'] = 'style=raw'
63 68 > process(hgwebdir({'repo': '.'}))
64 69 > EOF
65 70 $ python request.py
66 71 ---- STATUS
67 72 200 Script output follows
68 73 ---- HEADERS
69 74 [('Content-Type', 'application/atom+xml; charset=ascii')]
70 75 ---- DATA
71 76 <?xml version="1.0" encoding="ascii"?>
72 77 <feed xmlns="http://www.w3.org/2005/Atom">
73 78 <!-- Changelog -->
74 79 <id>http://127.0.0.1:$HGPORT/</id>
75 80 <link rel="self" href="http://127.0.0.1:$HGPORT/atom-log"/>
76 81 <link rel="alternate" href="http://127.0.0.1:$HGPORT/"/>
77 82 <title>repo Changelog</title>
78 83 <updated>1970-01-01T00:00:00+00:00</updated>
79 84
80 85 <entry>
81 86 <title>[default] test</title>
82 87 <id>http://127.0.0.1:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id>
83 88 <link href="http://127.0.0.1:$HGPORT/rev/61c9426e69fe"/>
84 89 <author>
85 90 <name>test</name>
86 91 <email>&#116;&#101;&#115;&#116;</email>
87 92 </author>
88 93 <updated>1970-01-01T00:00:00+00:00</updated>
89 94 <published>1970-01-01T00:00:00+00:00</published>
90 95 <content type="xhtml">
91 96 <table xmlns="http://www.w3.org/1999/xhtml">
92 97 <tr>
93 98 <th style="text-align:left;">changeset</th>
94 99 <td>61c9426e69fe</td>
95 100 </tr>
96 101 <tr>
97 102 <th style="text-align:left;">branch</th>
98 103 <td>default</td>
99 104 </tr>
100 105 <tr>
101 106 <th style="text-align:left;">bookmark</th>
102 107 <td></td>
103 108 </tr>
104 109 <tr>
105 110 <th style="text-align:left;">tag</th>
106 111 <td>tip</td>
107 112 </tr>
108 113 <tr>
109 114 <th style="text-align:left;">user</th>
110 115 <td>&#116;&#101;&#115;&#116;</td>
111 116 </tr>
112 117 <tr>
113 118 <th style="text-align:left;vertical-align:top;">description</th>
114 119 <td>test</td>
115 120 </tr>
116 121 <tr>
117 122 <th style="text-align:left;vertical-align:top;">files</th>
118 123 <td>bar<br /></td>
119 124 </tr>
120 125 </table>
121 126 </content>
122 127 </entry>
123 128
124 129 </feed>
125 130 ---- ERRORS
126 131
127 132 ---- STATUS
128 133 200 Script output follows
129 134 ---- HEADERS
130 135 [('Content-Type', 'text/plain; charset=ascii')]
131 136 ---- DATA
132 137
133 138 /repo/
134 139
135 140 ---- ERRORS
136 141
137 142
138 143 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now