~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2008-03-16 08:25:21 UTC
  • mto: (3280.2.2 prepare-1.3)
  • mto: This revision was merged to the branch mainline in revision 3284.
  • Revision ID: mbp@sourcefrog.net-20080316082521-xmex8wq1uyj6cxyh
Fix doctest syntax

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
import signal
22
22
import subprocess
 
23
import sys
23
24
import threading
24
25
 
25
 
from bzrlib import errors
 
26
from bzrlib import (
 
27
    errors,
 
28
    osutils,
 
29
    revision as _mod_revision,
 
30
    )
26
31
from bzrlib.branch import Branch
27
32
from bzrlib.bzrdir import BzrDir
28
33
from bzrlib.errors import ParamikoNotPresent
 
34
from bzrlib.smart import medium
29
35
from bzrlib.tests import TestCaseWithTransport, TestSkipped
30
 
from bzrlib.transport import get_transport, smart
 
36
from bzrlib.transport import get_transport, remote
31
37
 
32
38
 
33
39
class TestBzrServe(TestCaseWithTransport):
39
45
        process.stdin.close()
40
46
        # Hide stdin from the subprocess module, so it won't fail to close it.
41
47
        process.stdin = None
42
 
        result = self.finish_bzr_subprocess(process, retcode=0)
 
48
        result = self.finish_bzr_subprocess(process)
43
49
        self.assertEqual('', result[0])
44
50
        self.assertEqual('', result[1])
45
51
    
64
70
        # Connect to the server
65
71
        # We use this url because while this is no valid URL to connect to this
66
72
        # server instance, the transport needs a URL.
67
 
        medium = smart.SmartSimplePipesClientMedium(
 
73
        client_medium = medium.SmartSimplePipesClientMedium(
68
74
            process.stdout, process.stdin)
69
 
        transport = smart.SmartTransport('bzr://localhost/', medium=medium)
 
75
        transport = remote.RemoteTransport(
 
76
            'bzr://localhost/', medium=client_medium)
70
77
        return process, transport
71
78
 
72
79
    def start_server_port(self, extra_options=()):
101
108
        # We get a working branch
102
109
        branch = BzrDir.open_from_transport(transport).open_branch()
103
110
        branch.repository.get_revision_graph()
104
 
        self.assertEqual(None, branch.last_revision())
 
111
        self.assertEqual(_mod_revision.NULL_REVISION,
 
112
                         _mod_revision.ensure_null(branch.last_revision()))
105
113
        self.assertInetServerShutsdownCleanly(process)
106
114
 
107
115
    def test_bzr_serve_port_readonly(self):
122
130
 
123
131
        # We get a working branch
124
132
        branch.repository.get_revision_graph()
125
 
        self.assertEqual(None, branch.last_revision())
 
133
        self.assertEqual(_mod_revision.NULL_REVISION,
 
134
                         _mod_revision.ensure_null(branch.last_revision()))
126
135
 
127
136
        self.assertServerFinishesCleanly(process)
128
137
 
129
 
    def test_bzr_serve_no_args(self):
130
 
        """'bzr serve' with no arguments or options should not traceback."""
131
 
        out, err = self.run_bzr_error(
132
 
            ['bzr serve requires one of --inet or --port'], 'serve')
133
 
 
134
138
    def test_bzr_connect_to_bzr_ssh(self):
135
139
        """User acceptance that get_transport of a bzr+ssh:// behaves correctly.
136
140
 
192
196
 
193
197
        # Access the branch via a bzr+ssh URL.  The BZR_REMOTE_PATH environment
194
198
        # variable is used to tell bzr what command to run on the remote end.
195
 
        path_to_branch = os.path.abspath('a_branch')
 
199
        path_to_branch = osutils.abspath('a_branch')
196
200
        
197
201
        orig_bzr_remote_path = os.environ.get('BZR_REMOTE_PATH')
198
 
        os.environ['BZR_REMOTE_PATH'] = self.get_bzr_path()
 
202
        bzr_remote_path = self.get_bzr_path()
 
203
        if sys.platform == 'win32':
 
204
            bzr_remote_path = sys.executable + ' ' + self.get_bzr_path()
 
205
        os.environ['BZR_REMOTE_PATH'] = bzr_remote_path
199
206
        try:
 
207
            if sys.platform == 'win32':
 
208
                path_to_branch = os.path.splitdrive(path_to_branch)[1]
200
209
            branch = Branch.open(
201
210
                'bzr+ssh://fred:secret@localhost:%d%s' % (port, path_to_branch))
202
211
            
203
212
            branch.repository.get_revision_graph()
204
 
            self.assertEqual(None, branch.last_revision())
 
213
            self.assertEqual(_mod_revision.NULL_REVISION,
 
214
                             _mod_revision.ensure_null(branch.last_revision()))
205
215
            # Check we can perform write operations
206
216
            branch.bzrdir.root_transport.mkdir('foo')
207
217
        finally:
214
224
 
215
225
        self.assertEqual(
216
226
            ['%s serve --inet --directory=/ --allow-writes'
217
 
             % self.get_bzr_path()],
 
227
             % bzr_remote_path],
218
228
            self.command_executed)
219
229