748
748
self.assertEqual([], sorted_list(u'.'))
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'.'))
758
# XXX: If that intends to check that list_dir gives a list of unicode,
759
# it's buggy because ['a'] == [u'a']. If that's not the intention, then
760
# it's just confusing. -- David Allouche 2006-08-11
762
[u'a', u'a%2525b', u'b', u'c', u'c2'], sorted_list(u'.'))
757
763
self.assertEqual([u'd', u'e'], sorted_list(u'c'))
759
765
if not t.is_readonly():
763
769
os.unlink('wd/c/d')
764
770
os.unlink('wd/b')
766
self.assertEqual([u'a', u'c', u'c2'], sorted_list('.'))
772
self.assertEqual([u'a', u'a%2525b', u'c', u'c2'], sorted_list('.'))
767
773
self.assertEqual([u'e'], sorted_list(u'c'))
769
775
self.assertListRaises(PathError, t.list_dir, 'q')
879
886
self.assertEqual(paths,
880
887
set(['isolated/dir/foo',
881
888
'isolated/dir/bar',
889
'isolated/dir/b%2525z',
882
890
'isolated/bar']))
883
891
sub_transport = transport.clone('isolated')
884
892
paths = set(sub_transport.iter_files_recursive())
885
self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
893
self.assertEqual(paths,
894
set(['dir/foo', 'dir/bar', 'dir/b%2525z', 'bar']))
896
def test_copy_tree(self):
897
# TODO: test file contents and permissions are preserved. This test was
898
# added just to ensure that quoting was handled correctly.
899
# -- David Allouche 2006-08-11
900
transport = self.get_transport()
901
if not transport.listable():
902
self.assertRaises(TransportNotPossible,
903
transport.iter_files_recursive)
905
if transport.is_readonly():
906
self.assertRaises(TransportNotPossible,
907
transport.put, 'a', 'some text for a\n')
909
self.build_tree(['from/',
913
'from/dir/b%25z', # make sure quoting is correct
916
transport.copy_tree('from', 'to')
917
paths = set(transport.iter_files_recursive())
918
self.assertEqual(paths,
887
928
def test_unicode_paths(self):
888
929
"""Test that we can read/write files with Unicode names."""