45
44
u_d_s_stat = os.lstat('unknown dir to skip')
46
45
u_d_f_stat = os.lstat('unknown dir/a file')
47
46
expected_dirblocks = [
48
(('', '', tree.inventory.root.file_id),
47
(('', tree.inventory.root.file_id),
50
('unknown dir', 'unknown dir', 'directory', u_d_stat, 'unknown dir', None, None),
51
('unknown dir to skip', 'unknown dir to skip', 'directory', u_d_s_stat, 'unknown dir to skip', None, None),
52
('unknown file', 'unknown file', 'file', u_f_stat, 'unknown file', None, None),
55
(('unknown dir', 'unknown dir', None),
56
[('unknown dir/a file', 'a file', 'file', u_d_f_stat, 'unknown dir/a file', None, None),
49
('unknown dir', 'unknown dir', 'directory', u_d_stat, None, None),
50
('unknown dir to skip', 'unknown dir to skip', 'directory', u_d_s_stat, None, None),
51
('unknown file', 'unknown file', 'file', u_f_stat, None, None),
54
(('unknown dir', None),
55
[('unknown dir/a file', 'a file', 'file', u_d_f_stat, None, None),
59
return tree, expected_dirblocks
61
def test_walkdir_unknowns(self):
62
"""unknown files and directories should be reported by walkdirs."""
60
63
# test that its iterable by iterating, and that skipping an unknown dir
66
tree, expected_dirblocks = self.get_tree_with_unknowns()
63
67
found_unknown_to_skip = False
64
68
for dirinfo, dirblock in tree.walkdirs():
65
69
result.append((dirinfo, list(dirblock)))
71
75
for pos, item in enumerate(expected_dirblocks):
72
76
self.assertEqual(item, result[pos])
73
77
self.assertTrue(found_unknown_to_skip)
79
def test_walkdir_from_unknown_dir(self):
80
"""Doing a walkdir when the requested prefix is unknown but on disk."""
82
tree, expected_dirblocks = self.get_tree_with_unknowns()
83
for dirinfo, dirblock in tree.walkdirs('unknown dir'):
84
result.append((dirinfo, list(dirblock)))
85
# check each return value for debugging ease.
86
for pos, item in enumerate(expected_dirblocks[1:]):
87
self.assertEqual(item, result[pos])