~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-04-23 02:29:35 UTC
  • mfrom: (2441 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2442.
  • Revision ID: robertc@robertcollins.net-20070423022935-9hhongamvk6bfdso
Resolve conflicts with bzr.dev.

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
from bzrlib.osutils import has_symlinks
19
20
from bzrlib.tests.tree_implementations import TestCaseWithTree
20
21
 
21
22
 
22
23
class TestWalkdirs(TestCaseWithTree):
23
24
 
24
 
    def get_all_subdirs_expected(self, tree):
25
 
        return [
26
 
            (('', tree.path2id('')),
27
 
            [
28
 
             ('0file', '0file', 'file', None, '2file', 'file'),
29
 
             ('1top-dir', '1top-dir', 'directory', None, '1top-dir', 'directory'),
30
 
             (u'2utf\u1234file', u'2utf\u1234file', 'file', None,
31
 
                                     u'0utf\u1234file'.encode('utf8'), 'file'),
32
 
             ('symlink', 'symlink', 'symlink', None, 'symlink', 'symlink')
33
 
            ]),
34
 
            (('1top-dir', '1top-dir'),
35
 
            [('1top-dir/0file-in-1topdir', '0file-in-1topdir', 'file', None, '1file-in-1topdir', 'file'),
36
 
             ('1top-dir/1dir-in-1topdir', '1dir-in-1topdir', 'directory', None, '0dir-in-1topdir', 'directory'),
37
 
            ]),
38
 
            (('1top-dir/1dir-in-1topdir', '0dir-in-1topdir'),
39
 
            [
40
 
            ]),
41
 
            ]
 
25
    def get_all_subdirs_expected(self, tree, symlinks):
 
26
        if symlinks:
 
27
            return [
 
28
                (('', tree.path2id('')),
 
29
                [
 
30
                 ('0file', '0file', 'file', None, '2file', 'file'),
 
31
                 ('1top-dir', '1top-dir', 'directory', None, '1top-dir', 'directory'),
 
32
                 (u'2utf\u1234file', u'2utf\u1234file', 'file', None,
 
33
                                         u'0utf\u1234file'.encode('utf8'), 'file'),
 
34
                 ('symlink', 'symlink', 'symlink', None, 'symlink', 'symlink')
 
35
                ]),
 
36
                (('1top-dir', '1top-dir'),
 
37
                [('1top-dir/0file-in-1topdir', '0file-in-1topdir', 'file', None, '1file-in-1topdir', 'file'),
 
38
                 ('1top-dir/1dir-in-1topdir', '1dir-in-1topdir', 'directory', None, '0dir-in-1topdir', 'directory'),
 
39
                ]),
 
40
                (('1top-dir/1dir-in-1topdir', '0dir-in-1topdir'),
 
41
                [
 
42
                ]),
 
43
                ]
 
44
        else:
 
45
            return [
 
46
                (('', tree.path2id('')),
 
47
                [
 
48
                 ('0file', '0file', 'file', None, '2file', 'file'),
 
49
                 ('1top-dir', '1top-dir', 'directory', None, '1top-dir', 'directory'),
 
50
                 (u'2utf\u1234file', u'2utf\u1234file', 'file', None,
 
51
                                         u'0utf\u1234file'.encode('utf8'), 'file'),
 
52
                ]),
 
53
                (('1top-dir', '1top-dir'),
 
54
                [('1top-dir/0file-in-1topdir', '0file-in-1topdir', 'file', None, '1file-in-1topdir', 'file'),
 
55
                 ('1top-dir/1dir-in-1topdir', '1dir-in-1topdir', 'directory', None, '0dir-in-1topdir', 'directory'),
 
56
                ]),
 
57
                (('1top-dir/1dir-in-1topdir', '0dir-in-1topdir'),
 
58
                [
 
59
                ]),
 
60
                ]
42
61
 
43
62
    def test_walkdir_root(self):
44
 
        tree = self.get_tree_with_subdirs_and_all_content_types()
 
63
        tree = self.get_tree_with_subdirs_and_all_supported_content_types(has_symlinks())
45
64
        tree.lock_read()
46
 
        expected_dirblocks = self.get_all_subdirs_expected(tree)
 
65
        expected_dirblocks = self.get_all_subdirs_expected(tree, has_symlinks())
47
66
        # test that its iterable by iterating
48
67
        result = []
49
68
        for dirinfo, block in tree.walkdirs():
61
80
        self.assertEqual(len(expected_dirblocks), len(result))
62
81
            
63
82
    def test_walkdir_subtree(self):
64
 
        tree = self.get_tree_with_subdirs_and_all_content_types()
 
83
        tree = self.get_tree_with_subdirs_and_all_supported_content_types(has_symlinks())
65
84
        # test that its iterable by iterating
66
85
        result = []
67
86
        tree.lock_read()
68
 
        expected_dirblocks = self.get_all_subdirs_expected(tree)[1:]
 
87
        expected_dirblocks = self.get_all_subdirs_expected(tree, has_symlinks())[1:]
69
88
        for dirinfo, block in tree.walkdirs('1top-dir'):
70
89
            newblock = []
71
90
            for row in block: