746
746
t = t.clone('wd')
748
self.assertEqual([], sorted_list(u'.'))
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([u'a', u'b', u'c', u'c2'], sorted_list(u'.'))
757
self.assertEqual([u'd', u'e'], sorted_list(u'c'))
759
['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('.'))
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([u'a', u'c', u'c2'], sorted_list('.'))
767
self.assertEqual([u'e'], sorted_list(u'c'))
769
self.assertEqual(['a', 'a%2525b', 'c', 'c2'], sorted_list('.'))
770
self.assertEqual(['e'], sorted_list('c'))
769
772
self.assertListRaises(PathError, t.list_dir, 'q')
770
773
self.assertListRaises(PathError, t.list_dir, 'c/f')
879
883
self.assertEqual(paths,
880
884
set(['isolated/dir/foo',
881
885
'isolated/dir/bar',
886
'isolated/dir/b%2525z',
882
887
'isolated/bar']))
883
888
sub_transport = transport.clone('isolated')
884
889
paths = set(sub_transport.iter_files_recursive())
885
self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
890
self.assertEqual(paths,
891
set(['dir/foo', 'dir/bar', 'dir/b%2525z', 'bar']))
893
def test_copy_tree(self):
894
# TODO: test file contents and permissions are preserved. This test was
895
# added just to ensure that quoting was handled correctly.
896
# -- David Allouche 2006-08-11
897
transport = self.get_transport()
898
if not transport.listable():
899
self.assertRaises(TransportNotPossible,
900
transport.iter_files_recursive)
902
if transport.is_readonly():
903
self.assertRaises(TransportNotPossible,
904
transport.put, 'a', 'some text for a\n')
906
self.build_tree(['from/',
910
'from/dir/b%25z', # make sure quoting is correct
913
transport.copy_tree('from', 'to')
914
paths = set(transport.iter_files_recursive())
915
self.assertEqual(paths,
887
925
def test_unicode_paths(self):
888
926
"""Test that we can read/write files with Unicode names."""