/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: John Arbash Meinel
  • Date: 2008-07-08 14:55:19 UTC
  • mfrom: (3530 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080708145519-paqg4kjwbpgs2xmq
Merge bzr.dev 3530

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from bzrlib import (
32
32
    errors,
33
33
    osutils,
 
34
    tests,
34
35
    urlutils,
35
36
    )
36
37
from bzrlib.errors import (ConnectionError,
38
39
                           FileExists,
39
40
                           InvalidURL,
40
41
                           LockError,
41
 
                           NoSmartServer,
42
42
                           NoSuchFile,
43
43
                           NotLocalUrl,
44
44
                           PathError,
75
75
    def get_transport_test_permutations(self, module):
76
76
        """Get the permutations module wants to have tested."""
77
77
        if getattr(module, 'get_test_permutations', None) is None:
78
 
            raise AssertionError("transport module %s doesn't provide get_test_permutations()"
79
 
                    % module.__name__)
80
 
            ##warning("transport module %s doesn't provide get_test_permutations()"
81
 
            ##       % module.__name__)
 
78
            raise AssertionError(
 
79
                "transport module %s doesn't provide get_test_permutations()"
 
80
                % module.__name__)
82
81
            return []
83
82
        return module.get_test_permutations()
84
83
 
101
100
        return result
102
101
 
103
102
 
 
103
def load_tests(standard_tests, module, loader):
 
104
    """Multiply tests for tranport implementations."""
 
105
    result = loader.suiteClass()
 
106
    adapter = TransportTestProviderAdapter()
 
107
    for test in tests.iter_suite_tests(standard_tests):
 
108
        result.addTests(adapter.adapt(test))
 
109
    return result
 
110
 
104
111
 
105
112
class TransportTests(TestTransportImplementation):
106
113
 
170
177
        self.assertEqual(True, t.has_any(['b', 'b', 'b']))
171
178
 
172
179
    def test_has_root_works(self):
 
180
        from bzrlib.smart import server
 
181
        if self.transport_server is server.SmartTCPServer_for_testing:
 
182
            raise TestNotApplicable(
 
183
                "SmartTCPServer_for_testing intentionally does not allow "
 
184
                "access to /.")
173
185
        current_transport = self.get_transport()
174
186
        self.assertTrue(current_transport.has('/'))
175
187
        root = current_transport.clone('/')
939
951
        except TransportNotPossible:
940
952
            # ok, this transport does not support delete_tree
941
953
            return
942
 
        
 
954
 
943
955
        # did it delete that trivial case?
944
956
        self.assertRaises(NoSuchFile, t.stat, 'adir')
945
957
 
946
958
        self.build_tree(['adir/',
947
 
                         'adir/file', 
948
 
                         'adir/subdir/', 
949
 
                         'adir/subdir/file', 
 
959
                         'adir/file',
 
960
                         'adir/subdir/',
 
961
                         'adir/subdir/file',
950
962
                         'adir/subdir2/',
951
963
                         'adir/subdir2/file',
952
964
                         ], transport=t)
1033
1045
            return
1034
1046
 
1035
1047
        paths = ['a', 'b/', 'b/c', 'b/d/', 'b/d/e']
1036
 
        sizes = [14, 0, 16, 0, 18] 
 
1048
        sizes = [14, 0, 16, 0, 18]
1037
1049
        self.build_tree(paths, transport=t, line_endings='binary')
1038
1050
 
1039
1051
        for path, size in zip(paths, sizes):
1061
1073
    def test_list_dir(self):
1062
1074
        # TODO: Test list_dir, just try once, and if it throws, stop testing
1063
1075
        t = self.get_transport()
1064
 
        
 
1076
 
1065
1077
        if not t.listable():
1066
1078
            self.assertRaises(TransportNotPossible, t.list_dir, '.')
1067
1079
            return
1097
1109
        else:
1098
1110
            os.unlink('c/d')
1099
1111
            os.unlink('b')
1100
 
            
 
1112
 
1101
1113
        self.assertEqual(['a', 'a%2525b', 'c', 'c2'], sorted_list('.', t))
1102
1114
        self.assertEqual(['e'], sorted_list('c', t))
1103
1115
 
1114
1126
            self.build_tree(['a/', 'a/%'], transport=t)
1115
1127
        else:
1116
1128
            self.build_tree(['a/', 'a/%'])
1117
 
        
 
1129
 
1118
1130
        names = list(t.list_dir('a'))
1119
1131
        self.assertEqual(['%25'], names)
1120
1132
        self.assertIsInstance(names[0], str)
1585
1597
            self.assertTrue(result[0][0] <= 400)
1586
1598
            self.assertTrue(result[0][0] + data_len >= 1034)
1587
1599
            check_result_data(result)
 
1600
 
 
1601
    def test_readv_with_adjust_for_latency_with_big_file(self):
 
1602
        transport = self.get_transport()
1588
1603
        # test from observed failure case.
1589
1604
        if transport.is_readonly():
1590
1605
            file('a', 'w').write('a'*1024*1024)