748
748
self.assertEqual([], sorted_list('.'))
749
749
# c2 is precisely one letter longer than c here to test that
750
750
# suffixing is not confused.
751
# a%25b checks that quoting is done consistently across transports
752
tree_names = ['a', 'a%25b', 'b', 'c/', 'c/d', 'c/e', 'c2/']
751
753
if not t.is_readonly():
752
self.build_tree(['a', 'b', 'c/', 'c/d', 'c/e', 'c2/'], transport=t)
754
self.build_tree(tree_names, transport=t)
754
self.build_tree(['wd/a', 'wd/b', 'wd/c/', 'wd/c/d', 'wd/c/e', 'wd/c2/'])
756
self.build_tree(['wd/' + name for name in tree_names])
756
self.assertEqual(['a', 'b', 'c', 'c2'], sorted_list('.'))
759
['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('.'))
757
760
self.assertEqual(['d', 'e'], sorted_list('c'))
759
762
if not t.is_readonly():
763
766
os.unlink('wd/c/d')
764
767
os.unlink('wd/b')
766
self.assertEqual(['a', 'c', 'c2'], sorted_list('.'))
769
self.assertEqual(['a', 'a%2525b', 'c', 'c2'], sorted_list('.'))
767
770
self.assertEqual(['e'], sorted_list('c'))
769
772
self.assertListRaises(PathError, t.list_dir, 'q')
893
897
self.assertEqual(paths,
894
898
set(['isolated/dir/foo',
895
899
'isolated/dir/bar',
900
'isolated/dir/b%2525z',
896
901
'isolated/bar']))
897
902
sub_transport = transport.clone('isolated')
898
903
paths = set(sub_transport.iter_files_recursive())
899
self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
904
self.assertEqual(paths,
905
set(['dir/foo', 'dir/bar', 'dir/b%2525z', 'bar']))
907
def test_copy_tree(self):
908
# TODO: test file contents and permissions are preserved. This test was
909
# added just to ensure that quoting was handled correctly.
910
# -- David Allouche 2006-08-11
911
transport = self.get_transport()
912
if not transport.listable():
913
self.assertRaises(TransportNotPossible,
914
transport.iter_files_recursive)
916
if transport.is_readonly():
917
self.assertRaises(TransportNotPossible,
918
transport.put, 'a', 'some text for a\n')
920
self.build_tree(['from/',
924
'from/dir/b%25z', # make sure quoting is correct
927
transport.copy_tree('from', 'to')
928
paths = set(transport.iter_files_recursive())
929
self.assertEqual(paths,
901
939
def test_unicode_paths(self):
902
940
"""Test that we can read/write files with Unicode names."""