comparison tests/test-hgweb-no-path-info.t @ 12438:922d2078017a

tests: unify test-hgweb-no-path-info
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Sep 2010 13:41:32 -0500
parents tests/test-hgweb-no-path-info@f64b416b0ac8
children d08bb64888bc
comparison
equal deleted inserted replaced
12437:b5538f89e5aa 12438:922d2078017a
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
3 should be used from d74fc8dec2b4 onward to route the request.
4
5 $ mkdir repo
6 $ cd repo
7 $ hg init
8 $ echo foo > bar
9 $ hg add bar
10 $ hg commit -m "test"
11 $ hg tip
12 changeset: 0:61c9426e69fe
13 tag: tip
14 user: test
15 date: Thu Jan 01 00:00:00 1970 +0000
16 summary: test
17
18 $ cat > request.py <<EOF
19 > from mercurial.hgweb import hgweb, hgwebdir
20 > from StringIO import StringIO
21 > import os, sys
22 >
23 > errors = StringIO()
24 > input = StringIO()
25 >
26 > def startrsp(status, headers):
27 > print '---- STATUS'
28 > print status
29 > print '---- HEADERS'
30 > print [i for i in headers if i[0] != 'ETag']
31 > print '---- DATA'
32 > return output.write
33 >
34 > env = {
35 > 'wsgi.version': (1, 0),
36 > 'wsgi.url_scheme': 'http',
37 > 'wsgi.errors': errors,
38 > 'wsgi.input': input,
39 > 'wsgi.multithread': False,
40 > 'wsgi.multiprocess': False,
41 > 'wsgi.run_once': False,
42 > 'REQUEST_METHOD': 'GET',
43 > 'SCRIPT_NAME': '',
44 > 'SERVER_NAME': '127.0.0.1',
45 > 'SERVER_PORT': os.environ['HGPORT'],
46 > 'SERVER_PROTOCOL': 'HTTP/1.0'
47 > }
48 >
49 > def process(app):
50 > content = app(env, startrsp)
51 > sys.stdout.write(output.getvalue())
52 > sys.stdout.write(''.join(content))
53 > print '---- ERRORS'
54 > print errors.getvalue()
55 >
56 > output = StringIO()
57 > env['QUERY_STRING'] = 'style=atom'
58 > process(hgweb('.', name='repo'))
59 >
60 > output = StringIO()
61 > env['QUERY_STRING'] = 'style=raw'
62 > process(hgwebdir({'repo': '.'}))
63 > EOF
64 $ python request.py
65 ---- STATUS
66 200 Script output follows
67 ---- HEADERS
68 [('Content-Type', 'application/atom+xml; charset=ascii')]
69 ---- DATA
70 <?xml version="1.0" encoding="ascii"?>
71 <feed xmlns="http://www.w3.org/2005/Atom">
72 <!-- Changelog -->
73 <id>http://127.0.0.1:*/</id> (glob)
74 <link rel="self" href="http://127.0.0.1:*/atom-log"/> (glob)
75 <link rel="alternate" href="http://127.0.0.1:*/"/> (glob)
76 <title>repo Changelog</title>
77 <updated>1970-01-01T00:00:00+00:00</updated>
78
79 <entry>
80 <title>test</title>
81 <id>http://127.0.0.1:*/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
82 <link href="http://127.0.0.1:*/rev/61c9426e69fe"/> (glob)
83 <author>
84 <name>test</name>
85 <email>&#116;&#101;&#115;&#116;</email>
86 </author>
87 <updated>1970-01-01T00:00:00+00:00</updated>
88 <published>1970-01-01T00:00:00+00:00</published>
89 <content type="xhtml">
90 <div xmlns="http://www.w3.org/1999/xhtml">
91 <pre xml:space="preserve">test</pre>
92 </div>
93 </content>
94 </entry>
95
96 </feed>
97 ---- ERRORS
98
99 ---- STATUS
100 200 Script output follows
101 ---- HEADERS
102 [('Content-Type', 'text/plain; charset=ascii')]
103 ---- DATA
104
105 repo/
106
107 ---- ERRORS
108