~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_walkdirs.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-16 21:05:46 UTC
  • mfrom: (2408.1.8 selftest.win32)
  • Revision ID: pqm@pqm.ubuntu.com-20070416210546-4ib7pt7wkkk71zzj
(bialix,r=john) win32-related selftest improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
 
21
21
from bzrlib import transform
 
22
from bzrlib.osutils import has_symlinks
 
23
from bzrlib.tests import TestSkipped
22
24
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
23
25
 
24
26
# tests to write:
137
139
 
138
140
    def test_walkdirs_type_changes(self):
139
141
        """Walkdir shows the actual kinds on disk and the recorded kinds."""
 
142
        if not has_symlinks():
 
143
            raise TestSkipped('No symlink support')
140
144
        tree = self.make_branch_and_tree('.')
141
145
        paths = ['file1', 'file2', 'dir1/', 'dir2/']
142
146
        ids = ['file1', 'file2', 'dir1', 'dir2']
199
203
        for pos, item in enumerate(expected_dirblocks):
200
204
            self.assertEqual(item, result[pos])
201
205
        self.assertEqual(len(expected_dirblocks), len(result))
 
206
 
 
207
    def test_walkdirs_type_changes_wo_symlinks(self):
 
208
        # similar to test_walkdirs_type_changes
 
209
        # but don't use symlinks for safe testing on win32
 
210
        tree = self.make_branch_and_tree('.')
 
211
        paths = ['file1', 'dir1/']
 
212
        ids = ['file1', 'dir1']
 
213
        self.build_tree(paths)
 
214
        tree.add(paths, ids)
 
215
        tree.bzrdir.root_transport.delete_tree('dir1')
 
216
        tree.bzrdir.root_transport.delete('file1')
 
217
        changed_paths = ['dir1', 'file1/']
 
218
        self.build_tree(changed_paths)
 
219
        dir1_stat = os.lstat('dir1')
 
220
        file1_stat = os.lstat('file1')
 
221
        expected_dirblocks = [
 
222
             (('', tree.path2id('')),
 
223
              [('dir1', 'dir1', 'file', dir1_stat, 'dir1', 'directory'),
 
224
               ('file1', 'file1', 'directory', file1_stat, 'file1', 'file'),
 
225
              ]
 
226
             ),
 
227
             (('dir1', 'dir1'),
 
228
              [
 
229
              ]
 
230
             ),
 
231
             (('file1', None),
 
232
              [
 
233
              ]
 
234
             ),
 
235
            ]
 
236
        tree.lock_read()
 
237
        result = list(tree.walkdirs())
 
238
        tree.unlock()
 
239
        # check each return value for debugging ease.
 
240
        for pos, item in enumerate(expected_dirblocks):
 
241
            self.assertEqual(item, result[pos])
 
242
        self.assertEqual(len(expected_dirblocks), len(result))