~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/HTTPTestUtil.py

Merge in bzr-dir phase 2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
 
19
 
 
20
 
from bzrlib.tests import TestCaseInTempDir
21
 
from bzrlib.transport.http import HttpServer
22
 
from bzrlib.osutils import relpath
23
 
 
24
 
 
25
 
class TestCaseWithWebserver(TestCaseInTempDir):
26
 
    """Derived class that starts a localhost-only webserver.
27
 
    (in addition to what TestCaseInTempDir does).
28
 
 
29
 
    This is useful for testing things with a web server.
 
19
import bzrlib
 
20
from bzrlib.tests import TestCaseWithTransport
 
21
 
 
22
 
 
23
class TestCaseWithWebserver(TestCaseWithTransport):
 
24
    """A support class that provides readonly urls that are http://.
 
25
 
 
26
    This is done by forcing the readonly server to be an http one. This 
 
27
    will current fail if the primary transport is not backed by regular disk
 
28
    files.
30
29
    """
31
30
 
32
 
    def get_remote_url(self, path):
33
 
 
34
 
        if os.path.isabs(path):
35
 
            remote_path = relpath(self.test_dir, path)
36
 
        else:
37
 
            remote_path = path
38
 
        return self.server.get_url() + remote_path
39
 
 
40
31
    def setUp(self):
41
32
        super(TestCaseWithWebserver, self).setUp()
42
 
        self.server = HttpServer()
43
 
        self.server.setUp()
44
 
        self.addCleanup(self.server.tearDown)
 
33
        self.transport_readonly_server = bzrlib.transport.http.HttpServer