~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2009-03-24 05:21:02 UTC
  • mfrom: (4192 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4202.
  • Revision ID: mbp@sourcefrog.net-20090324052102-8kk087b32tep3d9h
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the generic Tree.walkdirs interface."""
18
18
 
 
19
import os
 
20
 
 
21
from bzrlib import tests
19
22
from bzrlib.osutils import has_symlinks
20
23
from bzrlib.tests.tree_implementations import TestCaseWithTree
21
24
 
78
81
        for pos, item in enumerate(expected_dirblocks):
79
82
            self.assertEqual(item, result[pos])
80
83
        self.assertEqual(len(expected_dirblocks), len(result))
81
 
            
 
84
 
82
85
    def test_walkdir_subtree(self):
83
86
        tree = self.get_tree_with_subdirs_and_all_supported_content_types(has_symlinks())
84
87
        # test that its iterable by iterating
98
101
        for pos, item in enumerate(expected_dirblocks):
99
102
            self.assertEqual(item, result[pos])
100
103
        self.assertEqual(len(expected_dirblocks), len(result))
 
104
 
 
105
    def test_walkdir_versioned_kind(self):
 
106
        work_tree = self.make_branch_and_tree('tree')
 
107
        work_tree.set_root_id('tree-root')
 
108
        self.build_tree(['tree/file', 'tree/dir/'])
 
109
        work_tree.add(['file', 'dir'], ['file-id', 'dir-id'])
 
110
        os.unlink('tree/file')
 
111
        os.rmdir('tree/dir')
 
112
        tree = self._convert_tree(work_tree)
 
113
        tree.lock_read()
 
114
        self.addCleanup(tree.unlock)
 
115
        if tree.path2id('file') is None:
 
116
            raise tests.TestNotApplicable(
 
117
                'Tree type cannot represent dangling ids.')
 
118
        expected = [(('', 'tree-root'), [
 
119
            ('dir', 'dir', 'unknown', None, 'dir-id', 'directory'),
 
120
            ('file', 'file', 'unknown', None, 'file-id', 'file')]),
 
121
            (('dir', 'dir-id'), [])]
 
122
        self.assertEqual(expected, list(tree.walkdirs()))