/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: Robert Collins
  • Date: 2007-04-04 05:19:38 UTC
  • mfrom: (2395 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2401.
  • Revision ID: robertc@robertcollins.net-20070404051938-2lnvpsm2tbo5a6g2
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from bzrlib.symbol_versioning import zero_eleven
39
39
from bzrlib.tests import TestCaseInTempDir, TestSkipped
40
40
from bzrlib.tests.test_transport import TestTransportImplementation
41
 
from bzrlib.transport import memory, smart, chroot
 
41
from bzrlib.transport import memory, smart
42
42
import bzrlib.transport
43
43
 
44
44
 
45
 
def _append(fn, txt):
46
 
    """Append the given text (file-like object) to the supplied filename."""
47
 
    f = open(fn, 'ab')
48
 
    try:
49
 
        f.write(txt.read())
50
 
    finally:
51
 
        f.close()
52
 
 
53
 
 
54
45
class TransportTests(TestTransportImplementation):
55
46
 
56
47
    def check_transport_contents(self, content, transport, relpath):
76
67
 
77
68
    def test_has_root_works(self):
78
69
        current_transport = self.get_transport()
79
 
        if isinstance(current_transport, chroot.ChrootTransportDecorator):
80
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
81
70
        self.assertTrue(current_transport.has('/'))
82
71
        root = current_transport.clone('/')
83
72
        self.assertTrue(root.has(''))
1008
997
    def test_clone(self):
1009
998
        # TODO: Test that clone moves up and down the filesystem
1010
999
        t1 = self.get_transport()
1011
 
        if isinstance(t1, chroot.ChrootTransportDecorator):
1012
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
1013
1000
 
1014
1001
        self.build_tree(['a', 'b/', 'b/c'], transport=t1)
1015
1002
 
1042
1029
 
1043
1030
    def test_clone_to_root(self):
1044
1031
        orig_transport = self.get_transport()
1045
 
        if isinstance(orig_transport, chroot.ChrootTransportDecorator):
1046
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
1047
1032
        # Repeatedly go up to a parent directory until we're at the root
1048
1033
        # directory of this transport
1049
1034
        root_transport = orig_transport
1072
1057
    def test_clone_from_root(self):
1073
1058
        """At the root, cloning to a simple dir should just do string append."""
1074
1059
        orig_transport = self.get_transport()
1075
 
        if isinstance(orig_transport, chroot.ChrootTransportDecorator):
1076
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('/')")
1077
1060
        root_transport = orig_transport.clone('/')
1078
1061
        self.assertEqual(root_transport.base + '.bzr/',
1079
1062
            root_transport.clone('.bzr').base)
1094
1077
 
1095
1078
    def test_relpath_at_root(self):
1096
1079
        t = self.get_transport()
1097
 
        if isinstance(t, chroot.ChrootTransportDecorator):
1098
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
1099
1080
        # clone all the way to the top
1100
1081
        new_transport = t.clone('..')
1101
1082
        while new_transport.base != t.base:
1111
1092
        # that have aliasing problems like symlinks should go in backend
1112
1093
        # specific test cases.
1113
1094
        transport = self.get_transport()
1114
 
        if isinstance(transport, chroot.ChrootTransportDecorator):
1115
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
1116
1095
        
1117
1096
        self.assertEqual(transport.base + 'relpath',
1118
1097
                         transport.abspath('relpath'))
1137
1116
 
1138
1117
    def test_abspath_at_root(self):
1139
1118
        t = self.get_transport()
1140
 
        if isinstance(t, chroot.ChrootTransportDecorator):
1141
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
1142
1119
        # clone all the way to the top
1143
1120
        new_transport = t.clone('..')
1144
1121
        while new_transport.base != t.base:
1243
1220
        # check that our server (whatever it is) is accessable reliably
1244
1221
        # via get_transport and multiple connections share content.
1245
1222
        transport = self.get_transport()
1246
 
        if isinstance(transport, chroot.ChrootTransportDecorator):
1247
 
            raise TestSkipped("ChrootTransportDecorator disallows clone('..')")
1248
1223
        if transport.is_readonly():
1249
1224
            return
1250
1225
        transport.put_bytes('foo', 'bar')
1330
1305
        """
1331
1306
        transport = self.get_transport()
1332
1307
        try:
1333
 
            medium = transport.get_smart_medium()
1334
 
            self.assertIsInstance(medium, smart.SmartClientMedium)
 
1308
            client_medium = transport.get_smart_medium()
 
1309
            self.assertIsInstance(client_medium, smart.SmartClientMedium)
1335
1310
        except errors.NoSmartMedium:
1336
1311
            # as long as we got it we're fine
1337
1312
            pass