|
1 from cubicweb.devtools.apptest import EnvBasedTC |
|
2 from cubicweb.etwist.server import host_prefixed_baseurl |
|
3 |
|
4 |
|
5 class HostPrefixedBaseURLTC(EnvBasedTC): |
|
6 |
|
7 def _check(self, baseurl, host, waited): |
|
8 self.assertEquals(host_prefixed_baseurl(baseurl, host), waited, |
|
9 'baseurl %s called through host %s should be considered as %s' |
|
10 % (baseurl, host, waited)) |
|
11 |
|
12 def test1(self): |
|
13 self._check('http://www.cubicweb.org/hg/', 'code.cubicweb.org', |
|
14 'http://code.cubicweb.org/hg/') |
|
15 |
|
16 def test2(self): |
|
17 self._check('http://www.cubicweb.org/hg/', 'cubicweb.org', |
|
18 'http://www.cubicweb.org/hg/') |
|
19 |
|
20 def test3(self): |
|
21 self._check('http://cubicweb.org/hg/', 'code.cubicweb.org', |
|
22 'http://code.cubicweb.org/hg/') |
|
23 |
|
24 def test4(self): |
|
25 self._check('http://www.cubicweb.org/hg/', 'localhost', |
|
26 'http://www.cubicweb.org/hg/') |
|
27 |
|
28 def test5(self): |
|
29 self._check('http://www.cubicweb.org/cubes/', 'hg.code.cubicweb.org', |
|
30 'http://hg.code.cubicweb.org/cubes/') |
|
31 |
|
32 def test6(self): |
|
33 self._check('http://localhost:8080/hg/', 'code.cubicweb.org', |
|
34 'http://localhost:8080/hg/') |
|
35 |