Mercurial > hg
annotate tests/test-wsgirequest.py @ 52182:bd8081e9fd62
rust: don't star export from the `revlog` module
This made a lot of the imports confusing because they didn't make sense
at the top level (so, outside of `revlog`), and they hide the more common
types when autocompleting.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 26 Sep 2024 14:26:24 +0200 |
parents | 9ed281bbf864 |
children |
rev | line source |
---|---|
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 import unittest |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
3 from mercurial.hgweb import request as requestmod |
45004
2632c1ed8f34
hgweb: encode WSGI environment like OS environment
Manuel Jacob <me@manueljacob.de>
parents:
43506
diff
changeset
|
4 from mercurial import error, pycompat |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 DEFAULT_ENV = { |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
7 'REQUEST_METHOD': 'GET', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
8 'SERVER_NAME': 'testserver', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
9 'SERVER_PORT': '80', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
10 'SERVER_PROTOCOL': 'http', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
11 'wsgi.version': (1, 0), |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
12 'wsgi.url_scheme': 'http', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
13 'wsgi.input': None, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
14 'wsgi.errors': None, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
15 'wsgi.multithread': False, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
16 'wsgi.multiprocess': True, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
17 'wsgi.run_once': False, |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 } |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
20 |
36911
f0a851542a05
hgweb: remove wsgirequest (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36900
diff
changeset
|
21 def parse(env, reponame=None, altbaseurl=None, extra=None): |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 env = dict(env) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 env.update(extra or {}) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
25 return requestmod.parserequestfromenv( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
26 env, reponame=reponame, altbaseurl=altbaseurl |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
27 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
28 |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 class ParseRequestTests(unittest.TestCase): |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 def testdefault(self): |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 r = parse(DEFAULT_ENV) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 self.assertEqual(r.url, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 self.assertEqual(r.advertisedurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 self.assertEqual(r.urlscheme, b'http') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 self.assertEqual(r.method, b'GET') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 self.assertIsNone(r.remoteuser) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 self.assertIsNone(r.remotehost) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 self.assertEqual(r.apppath, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 self.assertEqual(r.dispatchparts, []) |
36898
d0b0fedbfb53
hgweb: change how dispatch path is reported
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36897
diff
changeset
|
43 self.assertIsNone(r.dispatchpath) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 self.assertIsNone(r.reponame) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 self.assertEqual(r.querystring, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 self.assertEqual(len(r.qsparams), 0) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 self.assertEqual(len(r.headers), 0) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 def testcustomport(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
50 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
51 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
52 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
53 'SERVER_PORT': '8000', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
54 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
55 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 self.assertEqual(r.url, b'http://testserver:8000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 self.assertEqual(r.baseurl, b'http://testserver:8000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 self.assertEqual(r.advertisedurl, b'http://testserver:8000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 self.assertEqual(r.advertisedbaseurl, b'http://testserver:8000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
62 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
63 DEFAULT_ENV, |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
64 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
65 'SERVER_PORT': '4000', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
66 'wsgi.url_scheme': 'https', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
67 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
68 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 self.assertEqual(r.url, b'https://testserver:4000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 self.assertEqual(r.baseurl, b'https://testserver:4000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 self.assertEqual(r.advertisedurl, b'https://testserver:4000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 self.assertEqual(r.advertisedbaseurl, b'https://testserver:4000') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 def testhttphost(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
76 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
77 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
78 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
79 'HTTP_HOST': 'altserver', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
80 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
81 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 self.assertEqual(r.url, b'http://altserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 self.assertEqual(r.baseurl, b'http://altserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 self.assertEqual(r.advertisedurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 def testscriptname(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
89 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
90 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
91 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
92 'SCRIPT_NAME': '', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
93 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
94 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 self.assertEqual(r.url, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 self.assertEqual(r.advertisedurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 self.assertEqual(r.apppath, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 self.assertEqual(r.dispatchparts, []) |
36898
d0b0fedbfb53
hgweb: change how dispatch path is reported
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36897
diff
changeset
|
102 self.assertIsNone(r.dispatchpath) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
104 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
105 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
106 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
107 'SCRIPT_NAME': '/script', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
108 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
109 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 self.assertEqual(r.url, b'http://testserver/script') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 self.assertEqual(r.advertisedurl, b'http://testserver/script') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 self.assertEqual(r.apppath, b'/script') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 self.assertEqual(r.dispatchparts, []) |
36898
d0b0fedbfb53
hgweb: change how dispatch path is reported
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36897
diff
changeset
|
117 self.assertIsNone(r.dispatchpath) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
119 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
120 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
121 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
122 'SCRIPT_NAME': '/multiple words', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
123 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
124 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
125 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 self.assertEqual(r.url, b'http://testserver/multiple%20words') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 self.assertEqual(r.advertisedurl, b'http://testserver/multiple%20words') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 self.assertEqual(r.apppath, b'/multiple words') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 self.assertEqual(r.dispatchparts, []) |
36898
d0b0fedbfb53
hgweb: change how dispatch path is reported
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36897
diff
changeset
|
132 self.assertIsNone(r.dispatchpath) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 def testpathinfo(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
135 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
136 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
137 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
138 'PATH_INFO': '', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
139 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
140 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 self.assertEqual(r.url, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 self.assertEqual(r.advertisedurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 self.assertEqual(r.apppath, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 self.assertEqual(r.dispatchparts, []) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 self.assertEqual(r.dispatchpath, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
150 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
151 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
152 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
153 'PATH_INFO': '/pathinfo', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
154 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
155 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 self.assertEqual(r.url, b'http://testserver/pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 self.assertEqual(r.advertisedurl, b'http://testserver/pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
160 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 self.assertEqual(r.apppath, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 self.assertEqual(r.dispatchparts, [b'pathinfo']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 self.assertEqual(r.dispatchpath, b'pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
165 r = parse( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
166 DEFAULT_ENV, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
167 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
168 'PATH_INFO': '/one/two/', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
169 }, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
170 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
171 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
172 self.assertEqual(r.url, b'http://testserver/one/two/') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
173 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
174 self.assertEqual(r.advertisedurl, b'http://testserver/one/two/') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
175 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
176 self.assertEqual(r.apppath, b'') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
177 self.assertEqual(r.dispatchparts, [b'one', b'two']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 self.assertEqual(r.dispatchpath, b'one/two') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
180 def testscriptandpathinfo(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
181 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
182 DEFAULT_ENV, |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
183 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
184 'SCRIPT_NAME': '/script', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
185 'PATH_INFO': '/pathinfo', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
186 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
187 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
188 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 self.assertEqual(r.url, b'http://testserver/script/pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
190 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
191 self.assertEqual(r.advertisedurl, b'http://testserver/script/pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
192 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
193 self.assertEqual(r.apppath, b'/script') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
194 self.assertEqual(r.dispatchparts, [b'pathinfo']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
195 self.assertEqual(r.dispatchpath, b'pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
196 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
197 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
198 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
199 extra={ |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
200 'SCRIPT_NAME': '/script1/script2', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
201 'PATH_INFO': '/path1/path2', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
202 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
203 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
205 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
206 r.url, b'http://testserver/script1/script2/path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
207 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 self.assertEqual(r.baseurl, b'http://testserver') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
209 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
210 r.advertisedurl, b'http://testserver/script1/script2/path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
211 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
212 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
213 self.assertEqual(r.apppath, b'/script1/script2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
214 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
215 self.assertEqual(r.dispatchpath, b'path1/path2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
216 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
217 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
218 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
219 extra={ |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 'HTTP_HOST': 'hostserver', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
221 'SCRIPT_NAME': '/script', |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
222 'PATH_INFO': '/pathinfo', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
223 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
224 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
225 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
226 self.assertEqual(r.url, b'http://hostserver/script/pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
227 self.assertEqual(r.baseurl, b'http://hostserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
228 self.assertEqual(r.advertisedurl, b'http://testserver/script/pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
229 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
230 self.assertEqual(r.apppath, b'/script') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
231 self.assertEqual(r.dispatchparts, [b'pathinfo']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
232 self.assertEqual(r.dispatchpath, b'pathinfo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
233 |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
36911
diff
changeset
|
234 if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
36911
diff
changeset
|
235 # Python 3.7 deprecates the regex*p* version, but 2.7 lacks |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
36911
diff
changeset
|
236 # the regex version. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
237 assertRaisesRegex = ( # camelcase-required |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
238 unittest.TestCase.assertRaisesRegexp |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
239 ) |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
36911
diff
changeset
|
240 |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
241 def testreponame(self): |
36897
d7fd203e36cc
hgweb: refactor repository name URL parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36896
diff
changeset
|
242 """repository path components get stripped from URL.""" |
d7fd203e36cc
hgweb: refactor repository name URL parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36896
diff
changeset
|
243 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
244 with self.assertRaisesRegex( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
245 error.ProgrammingError, 'reponame requires PATH_INFO' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
246 ): |
36897
d7fd203e36cc
hgweb: refactor repository name URL parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36896
diff
changeset
|
247 parse(DEFAULT_ENV, reponame=b'repo') |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
248 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
249 with self.assertRaisesRegex( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
250 error.ProgrammingError, 'PATH_INFO does not begin with repo ' 'name' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
251 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
252 parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
253 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
254 reponame=b'repo', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
255 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
256 'PATH_INFO': '/pathinfo', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
257 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
258 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
259 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
260 with self.assertRaisesRegex( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
261 error.ProgrammingError, 'reponame prefix of PATH_INFO' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
262 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
263 parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
264 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
265 reponame=b'repo', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
266 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
267 'PATH_INFO': '/repoextra/path', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
268 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
269 ) |
36897
d7fd203e36cc
hgweb: refactor repository name URL parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36896
diff
changeset
|
270 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
271 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
272 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
273 reponame=b'repo', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
274 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
275 'PATH_INFO': '/repo/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
276 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
277 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
278 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
279 self.assertEqual(r.url, b'http://testserver/repo/path1/path2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
280 self.assertEqual(r.baseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
281 self.assertEqual(r.advertisedurl, b'http://testserver/repo/path1/path2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
282 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
283 self.assertEqual(r.apppath, b'/repo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
284 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
285 self.assertEqual(r.dispatchpath, b'path1/path2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
286 self.assertEqual(r.reponame, b'repo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
287 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
288 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
289 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
290 reponame=b'prefix/repo', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
291 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
292 'PATH_INFO': '/prefix/repo/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
293 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
294 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
295 |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
296 self.assertEqual(r.url, b'http://testserver/prefix/repo/path1/path2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
297 self.assertEqual(r.baseurl, b'http://testserver') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
298 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
299 r.advertisedurl, b'http://testserver/prefix/repo/path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
300 ) |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
301 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
302 self.assertEqual(r.apppath, b'/prefix/repo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
303 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
304 self.assertEqual(r.dispatchpath, b'path1/path2') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
305 self.assertEqual(r.reponame, b'prefix/repo') |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
306 |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
307 def testaltbaseurl(self): |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
308 # Simple hostname remap. |
37895
e0598133ac68
tests: migrate test-wsgirequest.py to Python 3
Augie Fackler <augie@google.com>
parents:
37715
diff
changeset
|
309 r = parse(DEFAULT_ENV, altbaseurl=b'http://altserver') |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
310 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
311 self.assertEqual(r.url, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
312 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
313 self.assertEqual(r.advertisedurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
314 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
315 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
316 self.assertEqual(r.apppath, b'') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
317 self.assertEqual(r.dispatchparts, []) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
318 self.assertIsNone(r.dispatchpath) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
319 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
320 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
321 # With a custom port. |
37895
e0598133ac68
tests: migrate test-wsgirequest.py to Python 3
Augie Fackler <augie@google.com>
parents:
37715
diff
changeset
|
322 r = parse(DEFAULT_ENV, altbaseurl=b'http://altserver:8000') |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
323 self.assertEqual(r.url, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
324 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
325 self.assertEqual(r.advertisedurl, b'http://altserver:8000') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
326 self.assertEqual(r.advertisedbaseurl, b'http://altserver:8000') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
327 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
328 self.assertEqual(r.apppath, b'') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
329 self.assertEqual(r.dispatchparts, []) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
330 self.assertIsNone(r.dispatchpath) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
331 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
332 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
333 # With a changed protocol. |
37895
e0598133ac68
tests: migrate test-wsgirequest.py to Python 3
Augie Fackler <augie@google.com>
parents:
37715
diff
changeset
|
334 r = parse(DEFAULT_ENV, altbaseurl=b'https://altserver') |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
335 self.assertEqual(r.url, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
336 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
337 self.assertEqual(r.advertisedurl, b'https://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
338 self.assertEqual(r.advertisedbaseurl, b'https://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
339 # URL scheme is defined as the actual scheme, not advertised. |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
340 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
341 self.assertEqual(r.apppath, b'') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
342 self.assertEqual(r.dispatchparts, []) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
343 self.assertIsNone(r.dispatchpath) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
344 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
345 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
346 # Need to specify explicit port number for proper https:// alt URLs. |
37895
e0598133ac68
tests: migrate test-wsgirequest.py to Python 3
Augie Fackler <augie@google.com>
parents:
37715
diff
changeset
|
347 r = parse(DEFAULT_ENV, altbaseurl=b'https://altserver:443') |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
348 self.assertEqual(r.url, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
349 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
350 self.assertEqual(r.advertisedurl, b'https://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
351 self.assertEqual(r.advertisedbaseurl, b'https://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
352 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
353 self.assertEqual(r.apppath, b'') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
354 self.assertEqual(r.dispatchparts, []) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
355 self.assertIsNone(r.dispatchpath) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
356 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
357 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
358 # With only PATH_INFO defined. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
359 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
360 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
361 altbaseurl=b'http://altserver', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
362 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
363 'PATH_INFO': '/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
364 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
365 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
366 self.assertEqual(r.url, b'http://testserver/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
367 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
368 self.assertEqual(r.advertisedurl, b'http://altserver/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
369 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
370 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
371 self.assertEqual(r.apppath, b'') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
372 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
373 self.assertEqual(r.dispatchpath, b'path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
374 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
375 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
376 # Path on alt URL. |
37895
e0598133ac68
tests: migrate test-wsgirequest.py to Python 3
Augie Fackler <augie@google.com>
parents:
37715
diff
changeset
|
377 r = parse(DEFAULT_ENV, altbaseurl=b'http://altserver/altpath') |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
378 self.assertEqual(r.url, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
379 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
380 self.assertEqual(r.advertisedurl, b'http://altserver/altpath') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
381 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
382 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
383 self.assertEqual(r.apppath, b'/altpath') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
384 self.assertEqual(r.dispatchparts, []) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
385 self.assertIsNone(r.dispatchpath) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
386 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
387 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
388 # With a trailing slash. |
37895
e0598133ac68
tests: migrate test-wsgirequest.py to Python 3
Augie Fackler <augie@google.com>
parents:
37715
diff
changeset
|
389 r = parse(DEFAULT_ENV, altbaseurl=b'http://altserver/altpath/') |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
390 self.assertEqual(r.url, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
391 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
392 self.assertEqual(r.advertisedurl, b'http://altserver/altpath/') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
393 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
394 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
395 self.assertEqual(r.apppath, b'/altpath/') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
396 self.assertEqual(r.dispatchparts, []) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
397 self.assertIsNone(r.dispatchpath) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
398 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
399 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
400 # PATH_INFO + path on alt URL. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
401 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
402 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
403 altbaseurl=b'http://altserver/altpath', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
404 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
405 'PATH_INFO': '/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
406 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
407 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
408 self.assertEqual(r.url, b'http://testserver/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
409 self.assertEqual(r.baseurl, b'http://testserver') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
410 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
411 r.advertisedurl, b'http://altserver/altpath/path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
412 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
413 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
414 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
415 self.assertEqual(r.apppath, b'/altpath') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
416 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
417 self.assertEqual(r.dispatchpath, b'path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
418 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
419 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
420 # PATH_INFO + path on alt URL with trailing slash. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
421 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
422 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
423 altbaseurl=b'http://altserver/altpath/', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
424 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
425 'PATH_INFO': '/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
426 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
427 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
428 self.assertEqual(r.url, b'http://testserver/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
429 self.assertEqual(r.baseurl, b'http://testserver') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
430 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
431 r.advertisedurl, b'http://altserver/altpath//path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
432 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
433 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
434 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
435 self.assertEqual(r.apppath, b'/altpath/') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
436 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
437 self.assertEqual(r.dispatchpath, b'path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
438 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
439 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
440 # Local SCRIPT_NAME is ignored. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
441 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
442 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
443 altbaseurl=b'http://altserver', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
444 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
445 'SCRIPT_NAME': '/script', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
446 'PATH_INFO': '/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
447 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
448 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
449 self.assertEqual(r.url, b'http://testserver/script/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
450 self.assertEqual(r.baseurl, b'http://testserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
451 self.assertEqual(r.advertisedurl, b'http://altserver/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
452 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
453 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
454 self.assertEqual(r.apppath, b'') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
455 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
456 self.assertEqual(r.dispatchpath, b'path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
457 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
458 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
459 # Use remote's path for script name, app path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
460 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
461 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
462 altbaseurl=b'http://altserver/altroot', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
463 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
464 'SCRIPT_NAME': '/script', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
465 'PATH_INFO': '/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
466 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
467 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
468 self.assertEqual(r.url, b'http://testserver/script/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
469 self.assertEqual(r.baseurl, b'http://testserver') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
470 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
471 r.advertisedurl, b'http://altserver/altroot/path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
472 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
473 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
474 self.assertEqual(r.urlscheme, b'http') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
475 self.assertEqual(r.apppath, b'/altroot') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
476 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
477 self.assertEqual(r.dispatchpath, b'path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
478 self.assertIsNone(r.reponame) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
479 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
480 # reponame is factored in properly. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
481 r = parse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
482 DEFAULT_ENV, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
483 reponame=b'repo', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
484 altbaseurl=b'http://altserver/altroot', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
485 extra={ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
486 'SCRIPT_NAME': '/script', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
487 'PATH_INFO': '/repo/path1/path2', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45004
diff
changeset
|
488 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
489 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
490 |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
491 self.assertEqual(r.url, b'http://testserver/script/repo/path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
492 self.assertEqual(r.baseurl, b'http://testserver') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
493 self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
494 r.advertisedurl, b'http://altserver/altroot/repo/path1/path2' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
495 ) |
36900
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
496 self.assertEqual(r.advertisedbaseurl, b'http://altserver') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
497 self.assertEqual(r.apppath, b'/altroot/repo') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
498 self.assertEqual(r.dispatchparts, [b'path1', b'path2']) |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
499 self.assertEqual(r.dispatchpath, b'path1/path2') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
500 self.assertEqual(r.reponame, b'repo') |
219b23359f4c
hgweb: support constructing URLs from an alternate base URL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36898
diff
changeset
|
501 |
45004
2632c1ed8f34
hgweb: encode WSGI environment like OS environment
Manuel Jacob <me@manueljacob.de>
parents:
43506
diff
changeset
|
502 def testenvencoding(self): |
50820
9ed281bbf864
hgweb: encode WSGI environment using the ISO-8859-1 codec
Manuel Jacob <me@manueljacob.de>
parents:
48875
diff
changeset
|
503 b = b''.join(pycompat.bytechr(i) for i in range(256)) |
9ed281bbf864
hgweb: encode WSGI environment using the ISO-8859-1 codec
Manuel Jacob <me@manueljacob.de>
parents:
48875
diff
changeset
|
504 r = parse(DEFAULT_ENV, extra={'foo': b.decode('iso8859-1')}) |
9ed281bbf864
hgweb: encode WSGI environment using the ISO-8859-1 codec
Manuel Jacob <me@manueljacob.de>
parents:
48875
diff
changeset
|
505 self.assertEqual(r.rawenv[b'foo'], b) |
45004
2632c1ed8f34
hgweb: encode WSGI environment like OS environment
Manuel Jacob <me@manueljacob.de>
parents:
43506
diff
changeset
|
506 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
507 |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
508 if __name__ == '__main__': |
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
509 import silenttestrunner |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37895
diff
changeset
|
510 |
36896
b2a3308d6a21
tests: add test coverage for parsing WSGI requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
511 silenttestrunner.main(__name__) |