etwist/test/unittest_server.py
changeset 9779 3f1685ac2f16
parent 9533 fa4051e29fbe
equal deleted inserted replaced
9778:23bad0114b84 9779:3f1685ac2f16
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 
    18 
    19 import os, os.path as osp, glob
    19 import os, os.path as osp, glob
    20 import urllib
    20 import urllib
    21 
    21 
    22 from cubicweb.devtools.testlib import CubicWebTC
       
    23 from cubicweb.devtools.httptest import CubicWebServerTC
    22 from cubicweb.devtools.httptest import CubicWebServerTC
    24 from cubicweb.etwist.server import host_prefixed_baseurl
       
    25 
       
    26 
       
    27 class HostPrefixedBaseURLTC(CubicWebTC):
       
    28 
       
    29     def _check(self, baseurl, host, waited):
       
    30         self.assertEqual(host_prefixed_baseurl(baseurl, host), waited,
       
    31                          'baseurl %s called through host %s should be considered as %s'
       
    32                          % (baseurl, host, waited))
       
    33 
       
    34     def test1(self):
       
    35         self._check('http://www.cubicweb.org/hg/', 'code.cubicweb.org',
       
    36                     'http://code.cubicweb.org/hg/')
       
    37 
       
    38     def test2(self):
       
    39         self._check('http://www.cubicweb.org/hg/', 'cubicweb.org',
       
    40                     'http://www.cubicweb.org/hg/')
       
    41 
       
    42     def test3(self):
       
    43         self._check('http://cubicweb.org/hg/', 'code.cubicweb.org',
       
    44                     'http://code.cubicweb.org/hg/')
       
    45 
       
    46     def test4(self):
       
    47         self._check('http://www.cubicweb.org/hg/', 'localhost',
       
    48                     'http://www.cubicweb.org/hg/')
       
    49 
       
    50     def test5(self):
       
    51         self._check('http://www.cubicweb.org/cubes/', 'hg.code.cubicweb.org',
       
    52                     'http://hg.code.cubicweb.org/cubes/')
       
    53 
       
    54     def test6(self):
       
    55         self._check('http://localhost:8080/hg/', 'code.cubicweb.org',
       
    56                     'http://localhost:8080/hg/')
       
    57 
    23 
    58 
    24 
    59 class ETwistHTTPTC(CubicWebServerTC):
    25 class ETwistHTTPTC(CubicWebServerTC):
    60     def test_put_content(self):
    26     def test_put_content(self):
    61         data = {'hip': 'hop'}
    27         data = {'hip': 'hop'}