~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_transport.py

  • Committer: Martin
  • Date: 2010-05-16 15:18:43 UTC
  • mfrom: (5235 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5239.
  • Revision ID: gzlist@googlemail.com-20100516151843-lu53u7caehm3ie3i
Merge bzr.dev to resolve conflicts in NEWS and _chk_map_pyx

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
52
52
    TestNotApplicable,
53
53
    multiply_tests,
54
54
    )
 
55
from bzrlib.tests import test_server
55
56
from bzrlib.tests.test_transport import TestTransportImplementation
56
57
from bzrlib.transport import (
57
58
    ConnectedTransport,
79
80
            permutations = get_transport_test_permutations(
80
81
                reduce(getattr, (module).split('.')[1:], __import__(module)))
81
82
            for (klass, server_factory) in permutations:
82
 
                scenario = (server_factory.__name__,
 
83
                scenario = ('%s,%s' % (klass.__name__, server_factory.__name__),
83
84
                    {"transport_class":klass,
84
85
                     "transport_server":server_factory})
85
86
                result.append(scenario)
170
171
        self.assertEqual(True, t.has_any(['b', 'b', 'b']))
171
172
 
172
173
    def test_has_root_works(self):
173
 
        from bzrlib.smart import server
174
 
        if self.transport_server is server.SmartTCPServer_for_testing:
 
174
        if self.transport_server is test_server.SmartTCPServer_for_testing:
175
175
            raise TestNotApplicable(
176
176
                "SmartTCPServer_for_testing intentionally does not allow "
177
177
                "access to /.")
203
203
        for content, f in itertools.izip(contents, content_f):
204
204
            self.assertEqual(content, f.read())
205
205
 
 
206
    def test_get_unknown_file(self):
 
207
        t = self.get_transport()
 
208
        files = ['a', 'b']
 
209
        contents = ['contents of a\n',
 
210
                    'contents of b\n',
 
211
                    ]
 
212
        self.build_tree(files, transport=t, line_endings='binary')
206
213
        self.assertRaises(NoSuchFile, t.get, 'c')
207
214
        self.assertListRaises(NoSuchFile, t.get_multi, ['a', 'b', 'c'])
208
215
        self.assertListRaises(NoSuchFile, t.get_multi, iter(['a', 'b', 'c']))
242
249
        for content, fname in zip(contents, files):
243
250
            self.assertEqual(content, t.get_bytes(fname))
244
251
 
 
252
    def test_get_bytes_unknown_file(self):
 
253
        t = self.get_transport()
 
254
 
245
255
        self.assertRaises(NoSuchFile, t.get_bytes, 'c')
246
256
 
247
257
    def test_get_with_open_write_stream_sees_all_content(self):
674
684
            for f in files:
675
685
                self.assertTransportMode(temp_transport, f, mode)
676
686
 
 
687
    def test_create_prefix(self):
 
688
        t = self.get_transport()
 
689
        sub = t.clone('foo').clone('bar')
 
690
        try:
 
691
            sub.create_prefix()
 
692
        except TransportNotPossible:
 
693
            self.assertTrue(t.is_readonly())
 
694
        else:
 
695
            self.assertTrue(t.has('foo/bar'))
 
696
 
677
697
    def test_append_file(self):
678
698
        t = self.get_transport()
679
699
 
1063
1083
        subdir.stat('./file')
1064
1084
        subdir.stat('.')
1065
1085
 
 
1086
    def test_hardlink(self):
 
1087
        from stat import ST_NLINK
 
1088
 
 
1089
        t = self.get_transport()
 
1090
 
 
1091
        source_name = "original_target"
 
1092
        link_name = "target_link"
 
1093
 
 
1094
        self.build_tree([source_name], transport=t)
 
1095
 
 
1096
        try:
 
1097
            t.hardlink(source_name, link_name)
 
1098
 
 
1099
            self.failUnless(t.has(source_name))
 
1100
            self.failUnless(t.has(link_name))
 
1101
 
 
1102
            st = t.stat(link_name)
 
1103
            self.failUnlessEqual(st[ST_NLINK], 2)
 
1104
        except TransportNotPossible:
 
1105
            raise TestSkipped("Transport %s does not support hardlinks." %
 
1106
                              self._server.__class__)
 
1107
 
 
1108
    def test_symlink(self):
 
1109
        from stat import S_ISLNK
 
1110
 
 
1111
        t = self.get_transport()
 
1112
 
 
1113
        source_name = "original_target"
 
1114
        link_name = "target_link"
 
1115
 
 
1116
        self.build_tree([source_name], transport=t)
 
1117
 
 
1118
        try:
 
1119
            t.symlink(source_name, link_name)
 
1120
 
 
1121
            self.failUnless(t.has(source_name))
 
1122
            self.failUnless(t.has(link_name))
 
1123
 
 
1124
            st = t.stat(link_name)
 
1125
            self.failUnless(S_ISLNK(st.st_mode))
 
1126
        except TransportNotPossible:
 
1127
            raise TestSkipped("Transport %s does not support symlinks." %
 
1128
                              self._server.__class__)
 
1129
        except IOError:
 
1130
            raise tests.KnownFailure("Paramiko fails to create symlinks during tests")
 
1131
 
1066
1132
    def test_list_dir(self):
1067
1133
        # TODO: Test list_dir, just try once, and if it throws, stop testing
1068
1134
        t = self.get_transport()
1477
1543
                 u'\u65e5', # Kanji person
1478
1544
                ]
1479
1545
 
 
1546
        no_unicode_support = getattr(self._server, 'no_unicode_support', False)
 
1547
        if no_unicode_support:
 
1548
            raise tests.KnownFailure("test server cannot handle unicode paths")
 
1549
 
1480
1550
        try:
1481
1551
            self.build_tree(files, transport=t, line_endings='binary')
1482
1552
        except UnicodeError: