~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2011-02-25 08:45:27 UTC
  • mto: This revision was merged to the branch mainline in revision 5695.
  • Revision ID: andrew.bennetts@canonical.com-20110225084527-0ucp7p00d00hoqon
Add another test.

Show diffs side-by-side

added added

removed removed

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