~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
753
755
        else:
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])
755
757
 
756
 
        self.assertEqual(['a', 'b', 'c', 'c2'], sorted_list('.'))
 
758
        self.assertEqual(
 
759
            ['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('.'))
757
760
        self.assertEqual(['d', 'e'], sorted_list('c'))
758
761
 
759
762
        if not t.is_readonly():
763
766
            os.unlink('wd/c/d')
764
767
            os.unlink('wd/b')
765
768
            
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'))
768
771
 
769
772
        self.assertListRaises(PathError, t.list_dir, 'q')
886
889
                         'isolated/dir/',
887
890
                         'isolated/dir/foo',
888
891
                         'isolated/dir/bar',
 
892
                         'isolated/dir/b%25z', # make sure quoting is correct
889
893
                         'isolated/bar'],
890
894
                        transport=transport)
891
895
        paths = set(transport.iter_files_recursive())
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']))
 
906
 
 
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)
 
915
            return
 
916
        if transport.is_readonly():
 
917
            self.assertRaises(TransportNotPossible,
 
918
                              transport.put, 'a', 'some text for a\n')
 
919
            return
 
920
        self.build_tree(['from/',
 
921
                         'from/dir/',
 
922
                         'from/dir/foo',
 
923
                         'from/dir/bar',
 
924
                         'from/dir/b%25z', # make sure quoting is correct
 
925
                         'from/bar'],
 
926
                        transport=transport)
 
927
        transport.copy_tree('from', 'to')
 
928
        paths = set(transport.iter_files_recursive())
 
929
        self.assertEqual(paths,
 
930
                    set(['from/dir/foo',
 
931
                         'from/dir/bar',
 
932
                         'from/dir/b%2525z',
 
933
                         'from/bar',
 
934
                         'to/dir/foo',
 
935
                         'to/dir/bar',
 
936
                         'to/dir/b%2525z',
 
937
                         'to/bar',]))
900
938
 
901
939
    def test_unicode_paths(self):
902
940
        """Test that we can read/write files with Unicode names."""