~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Andrew Bennetts
  • Date: 2006-09-13 03:53:13 UTC
  • mto: (1752.2.82 remote bzrdir)
  • mto: This revision was merged to the branch mainline in revision 2015.
  • Revision ID: andrew.bennetts@canonical.com-20060913035313-30489d7505552ad9
Add SSH support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
class SmartClientTests(tests.TestCase):
35
35
 
36
36
    def test_construct_smart_stream_client(self):
37
 
        # make a new client; this really wants two fifos or sockets
38
 
        # but the constructor should not do any IO
39
 
        client = smart.SmartStreamClient(None, None)
 
37
        # make a new client; this really wants a connector function that returns
 
38
        # two fifos or sockets but the constructor should not do any IO
 
39
        client = smart.SmartStreamClient(None)
40
40
 
41
41
 
42
42
class TCPClientTests(tests.TestCaseWithTransport):
113
113
        args = [sys.executable, sys.argv[0], 'serve', '--inet']
114
114
        child = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
115
115
                                 close_fds=True)
116
 
        conn = smart.SmartStreamClient(to_server=child.stdin, from_server=child.stdout)
 
116
        conn = smart.SmartStreamClient(lambda: (child.stdout, child.stdin))
117
117
        conn.query_version()
118
118
        conn.query_version()
119
119
        conn.disconnect()
160
160
        
161
161
    def test_get_error_enoent(self):
162
162
        """Error reported from server getting nonexistent file."""
 
163
        # The path in a raised NoSuchFile exception should be the precise path
 
164
        # asked for by the client. This gives meaningful and unsurprising errors
 
165
        # for users.
163
166
        try:
164
 
            self.transport.get('not a file')
 
167
            self.transport.get('not%20a%20file')
165
168
        except errors.NoSuchFile, e:
166
 
            self.assertEqual('/not a file', e.path)
 
169
            self.assertEqual('not%20a%20file', e.path)
167
170
        else:
168
171
            self.fail("get did not raise expected error")
169
172
 
171
174
        """Test that cloning reuses the same connection."""
172
175
        # we create a real connection not a loopback one, but it will use the
173
176
        # same server and pipes
174
 
        conn2 = smart.SmartTransport(self.transport.base, clone_from=self.transport)
 
177
        conn2 = self.transport.clone('.')
 
178
        # XXX: shouldn't this assert something?
 
179
        # assertIdentical(self.transport._client, conn2._client), perhaps?
175
180
 
176
181
    def test_remote_path(self):
177
182
        self.assertEquals('/foo/bar',
224
229
                     "doesn't look like a bundle: %r" % response.body)
225
230
        bundle = serializer.read_bundle(StringIO(response.body))
226
231
 
 
232
 
 
233
class SmartTransportRegistration(tests.TestCase):
 
234
 
 
235
    def test_registration(self):
 
236
        t = get_transport('bzr+ssh://example.com/path')
 
237
        self.assertIsInstance(t, smart.SmartSSHTransport)
 
238
        self.assertEqual('example.com', t._host)
 
239
 
 
240
 
227
241
# TODO: Client feature that does get_bundle and then installs that into a
228
242
# branch; this can be used in place of the regular pull/fetch operation when
229
243
# coming from a smart server.