etwist/test/unittest_server.py
author sylvain.thenault@logilab.fr
Wed, 13 May 2009 17:00:08 +0200
branchtls-sprint
changeset 1788 d6e6ad70e50a
parent 1543 dca9817bb337
child 1977 606923dff11b
permissions -rw-r--r--
check field isn't already instantiated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1543
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     1
from cubicweb.devtools.apptest import EnvBasedTC
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     2
from cubicweb.etwist.server import host_prefixed_baseurl
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     3
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     4
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     5
class HostPrefixedBaseURLTC(EnvBasedTC):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     6
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     7
    def _check(self, baseurl, host, waited):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     8
        self.assertEquals(host_prefixed_baseurl(baseurl, host), waited,
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
     9
                          'baseurl %s called through host %s should be considered as %s'
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    10
                          % (baseurl, host, waited))
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    11
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    12
    def test1(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    13
        self._check('http://www.cubicweb.org/hg/', 'code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    14
                    'http://code.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    15
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    16
    def test2(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    17
        self._check('http://www.cubicweb.org/hg/', 'cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    18
                    'http://www.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    19
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    20
    def test3(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    21
        self._check('http://cubicweb.org/hg/', 'code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    22
                    'http://code.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    23
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    24
    def test4(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    25
        self._check('http://www.cubicweb.org/hg/', 'localhost',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    26
                    'http://www.cubicweb.org/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    27
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    28
    def test5(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    29
        self._check('http://www.cubicweb.org/cubes/', 'hg.code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    30
                    'http://hg.code.cubicweb.org/cubes/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    31
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    32
    def test6(self):
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    33
        self._check('http://localhost:8080/hg/', 'code.cubicweb.org',
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    34
                    'http://localhost:8080/hg/')
dca9817bb337 fix use-request-subdomain option behaviour and add tests
Florent <florent@secondweb.fr>
parents:
diff changeset
    35