~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: Martin Pool
  • Date: 2008-06-11 02:36:40 UTC
  • mfrom: (3490 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3492.
  • Revision ID: mbp@sourcefrog.net-20080611023640-db0lqd75yueksdw7
Merge news

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,
74
75
    def get_transport_test_permutations(self, module):
75
76
        """Get the permutations module wants to have tested."""
76
77
        if getattr(module, 'get_test_permutations', None) is None:
77
 
            raise AssertionError("transport module %s doesn't provide get_test_permutations()"
78
 
                    % module.__name__)
79
 
            ##warning("transport module %s doesn't provide get_test_permutations()"
80
 
            ##       % module.__name__)
 
78
            raise AssertionError(
 
79
                "transport module %s doesn't provide get_test_permutations()"
 
80
                % module.__name__)
81
81
            return []
82
82
        return module.get_test_permutations()
83
83
 
100
100
        return result
101
101
 
102
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
 
103
111
 
104
112
class TransportTests(TestTransportImplementation):
105
113
 
943
951
        except TransportNotPossible:
944
952
            # ok, this transport does not support delete_tree
945
953
            return
946
 
        
 
954
 
947
955
        # did it delete that trivial case?
948
956
        self.assertRaises(NoSuchFile, t.stat, 'adir')
949
957
 
950
958
        self.build_tree(['adir/',
951
 
                         'adir/file', 
952
 
                         'adir/subdir/', 
953
 
                         'adir/subdir/file', 
 
959
                         'adir/file',
 
960
                         'adir/subdir/',
 
961
                         'adir/subdir/file',
954
962
                         'adir/subdir2/',
955
963
                         'adir/subdir2/file',
956
964
                         ], transport=t)
1037
1045
            return
1038
1046
 
1039
1047
        paths = ['a', 'b/', 'b/c', 'b/d/', 'b/d/e']
1040
 
        sizes = [14, 0, 16, 0, 18] 
 
1048
        sizes = [14, 0, 16, 0, 18]
1041
1049
        self.build_tree(paths, transport=t, line_endings='binary')
1042
1050
 
1043
1051
        for path, size in zip(paths, sizes):
1065
1073
    def test_list_dir(self):
1066
1074
        # TODO: Test list_dir, just try once, and if it throws, stop testing
1067
1075
        t = self.get_transport()
1068
 
        
 
1076
 
1069
1077
        if not t.listable():
1070
1078
            self.assertRaises(TransportNotPossible, t.list_dir, '.')
1071
1079
            return
1101
1109
        else:
1102
1110
            os.unlink('c/d')
1103
1111
            os.unlink('b')
1104
 
            
 
1112
 
1105
1113
        self.assertEqual(['a', 'a%2525b', 'c', 'c2'], sorted_list('.', t))
1106
1114
        self.assertEqual(['e'], sorted_list('c', t))
1107
1115
 
1118
1126
            self.build_tree(['a/', 'a/%'], transport=t)
1119
1127
        else:
1120
1128
            self.build_tree(['a/', 'a/%'])
1121
 
        
 
1129
 
1122
1130
        names = list(t.list_dir('a'))
1123
1131
        self.assertEqual(['%25'], names)
1124
1132
        self.assertIsInstance(names[0], str)
1589
1597
            self.assertTrue(result[0][0] <= 400)
1590
1598
            self.assertTrue(result[0][0] + data_len >= 1034)
1591
1599
            check_result_data(result)
 
1600
 
 
1601
    def test_readv_with_adjust_for_latency_with_big_file(self):
 
1602
        transport = self.get_transport()
1592
1603
        # test from observed failure case.
1593
1604
        if transport.is_readonly():
1594
1605
            file('a', 'w').write('a'*1024*1024)