~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_serve.py

  • Committer: Jelmer Vernooij
  • Date: 2010-04-30 11:03:59 UTC
  • mto: This revision was merged to the branch mainline in revision 5197.
  • Revision ID: jelmer@samba.org-20100430110359-ow3e3grh7sxy93pa
Remove more unused imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
"""Tests of the bzr serve command."""
19
19
 
20
20
import os
 
21
import os.path
21
22
import signal
 
23
import subprocess
 
24
import sys
22
25
import thread
23
26
import threading
24
27
 
25
28
from bzrlib import (
26
29
    builtins,
 
30
    debug,
27
31
    errors,
28
32
    osutils,
29
33
    revision as _mod_revision,
30
 
    transport,
31
34
    urlutils,
32
35
    )
33
36
from bzrlib.branch import Branch
34
37
from bzrlib.bzrdir import BzrDir
35
38
from bzrlib.smart import client, medium
36
 
from bzrlib.smart.server import (
37
 
    BzrServerFactory,
38
 
    SmartTCPServer,
39
 
    )
 
39
from bzrlib.smart.server import BzrServerFactory, SmartTCPServer
40
40
from bzrlib.tests import (
41
41
    TestCaseWithMemoryTransport,
42
42
    TestCaseWithTransport,
 
43
    TestSkipped,
43
44
    )
44
45
from bzrlib.trace import mutter
45
 
from bzrlib.transport import remote
 
46
from bzrlib.transport import get_transport, remote
46
47
 
47
48
 
48
49
class TestBzrServeBase(TestCaseWithTransport):
51
52
                                *func_args, **func_kwargs):
52
53
        """Run 'bzr serve', and run the given func in a thread once the server
53
54
        has started.
54
 
 
 
55
        
55
56
        When 'func' terminates, the server will be terminated too.
56
 
 
 
57
        
57
58
        Returns stdout and stderr.
58
59
        """
59
60
        # install hook
162
163
        url = 'bzr://localhost:%d/' % port
163
164
        self.permit_url(url)
164
165
        return process, url
165
 
 
 
166
    
166
167
    def test_bzr_serve_quiet(self):
167
168
        self.make_branch('.')
168
169
        args = ['--port', 'localhost:0', '--quiet']
191
192
    def test_bzr_serve_port_readonly(self):
192
193
        """bzr server should provide a read only filesystem by default."""
193
194
        process, url = self.start_server_port()
194
 
        t = transport.get_transport(url)
195
 
        self.assertRaises(errors.TransportNotPossible, t.mkdir, 'adir')
 
195
        transport = get_transport(url)
 
196
        self.assertRaises(errors.TransportNotPossible, transport.mkdir, 'adir')
196
197
        self.assertServerFinishesCleanly(process)
197
198
 
198
199
    def test_bzr_serve_port_readwrite(self):
223
224
        # -Dhpss, and does drop some hpss logging to the file.
224
225
        self.make_branch('.')
225
226
        log_fname = os.getcwd() + '/server.log'
226
 
        self.overrideEnv('BZR_LOG', log_fname)
 
227
        self._captureVar('BZR_LOG', log_fname)
227
228
        process, transport = self.start_server_inet(['-Dhpss'])
228
229
        branch = BzrDir.open_from_transport(transport).open_branch()
229
230
        self.make_read_requests(branch)
332
333
        self.assertEqual(base_url, self.bzr_serve_transport.base)
333
334
        self.assertEqual(base_dir,
334
335
            server_maker.get_base_path(self.bzr_serve_transport))
 
336