~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-16 01:47:06 UTC
  • mfrom: (1910.19.16 smart-server)
  • Revision ID: pqm@pqm.ubuntu.com-20060916014706-93f2994bdb0c0850
(spiv,mpool,robertc) Create a RPC protocol as the building blocks for a smart server

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    urlutils,
31
31
    )
32
32
from bzrlib.errors import (DirectoryNotEmpty, NoSuchFile, FileExists,
33
 
                           LockError, PathError,
 
33
                           LockError, NoSmartServer, PathError,
34
34
                           TransportNotPossible, ConnectionError,
35
35
                           InvalidURL)
36
36
from bzrlib.osutils import getcwd
37
37
from bzrlib.symbol_versioning import zero_eleven
38
38
from bzrlib.tests import TestCaseInTempDir, TestSkipped
39
39
from bzrlib.tests.test_transport import TestTransportImplementation
40
 
from bzrlib.transport import memory
 
40
from bzrlib.transport import memory, smart
41
41
import bzrlib.transport
42
42
 
43
43
 
145
145
        self.check_transport_contents('file-like\ncontents\n', t, 'b')
146
146
 
147
147
        self.assertRaises(NoSuchFile,
148
 
                          t.put, 'path/doesnt/exist/c', StringIO('contents'))
 
148
            self.applyDeprecated,
 
149
            zero_eleven,
 
150
            t.put, 'path/doesnt/exist/c', StringIO('contents'))
149
151
 
150
152
    def test_put_bytes(self):
151
153
        t = self.get_transport()
1085
1087
        # specific test cases.
1086
1088
        transport = self.get_transport()
1087
1089
        
1088
 
        # disabled because some transports might normalize urls in generating
1089
 
        # the abspath - eg http+pycurl-> just http -- mbp 20060308 
1090
1090
        self.assertEqual(transport.base + 'relpath',
1091
1091
                         transport.abspath('relpath'))
1092
1092
 
1236
1236
            self.assertRaises(TransportNotPossible, transport.lock_write, 'foo')
1237
1237
            return
1238
1238
        transport.put_bytes('lock', '')
1239
 
        transport.put('lock', StringIO())
1240
1239
        try:
1241
1240
            lock = transport.lock_write('lock')
1242
1241
        except TransportNotPossible:
1289
1288
        self.assertEqual(d[2], (0, '0'))
1290
1289
        self.assertEqual(d[3], (3, '34'))
1291
1290
 
 
1291
    def test_get_smart_client(self):
 
1292
        """All transports must either give a smart client, or know they can't.
 
1293
 
 
1294
        For some transports such as http this might depend on probing to see 
 
1295
        what's actually present on the other end.  (But we can adjust for that 
 
1296
        in the future.)
 
1297
        """
 
1298
        transport = self.get_transport()
 
1299
        try:
 
1300
            client = transport.get_smart_client()
 
1301
            # XXX: should be a more general class
 
1302
            self.assertIsInstance(client, smart.SmartStreamClient)
 
1303
        except NoSmartServer:
 
1304
            # as long as we got it we're fine
 
1305
            pass