~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2007-01-30 23:05:35 UTC
  • mto: This revision was merged to the branch mainline in revision 2259.
  • Revision ID: bialix@ukr.net-20070130230535-kx1rd478rtigyc3v
standalone installer: win98 support

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