~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

Merge bzr.dev (and fix NEWS)

Show diffs side-by-side

added added

removed removed

Lines of Context:
745
745
            os.mkdir('wd')
746
746
        t = t.clone('wd')
747
747
 
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)
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([u'a', u'b', u'c', u'c2'], sorted_list(u'.'))
757
 
        self.assertEqual([u'd', u'e'], sorted_list(u'c'))
 
758
        self.assertEqual(
 
759
            ['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('.'))
 
760
        self.assertEqual(['d', 'e'], sorted_list('c'))
758
761
 
759
762
        if not t.is_readonly():
760
763
            t.delete('c/d')
763
766
            os.unlink('wd/c/d')
764
767
            os.unlink('wd/b')
765
768
            
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'))
768
771
 
769
772
        self.assertListRaises(PathError, t.list_dir, 'q')
770
773
        self.assertListRaises(PathError, t.list_dir, 'c/f')
872
875
                         'isolated/dir/',
873
876
                         'isolated/dir/foo',
874
877
                         'isolated/dir/bar',
 
878
                         'isolated/dir/b%25z', # make sure quoting is correct
875
879
                         'isolated/bar'],
876
880
                        transport=transport)
877
881
        paths = set(transport.iter_files_recursive())
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']))
 
892
 
 
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)
 
901
            return
 
902
        if transport.is_readonly():
 
903
            self.assertRaises(TransportNotPossible,
 
904
                              transport.put, 'a', 'some text for a\n')
 
905
            return
 
906
        self.build_tree(['from/',
 
907
                         'from/dir/',
 
908
                         'from/dir/foo',
 
909
                         'from/dir/bar',
 
910
                         'from/dir/b%25z', # make sure quoting is correct
 
911
                         'from/bar'],
 
912
                        transport=transport)
 
913
        transport.copy_tree('from', 'to')
 
914
        paths = set(transport.iter_files_recursive())
 
915
        self.assertEqual(paths,
 
916
                    set(['from/dir/foo',
 
917
                         'from/dir/bar',
 
918
                         'from/dir/b%2525z',
 
919
                         'from/bar',
 
920
                         'to/dir/foo',
 
921
                         'to/dir/bar',
 
922
                         'to/dir/b%2525z',
 
923
                         'to/bar',]))
886
924
 
887
925
    def test_unicode_paths(self):
888
926
        """Test that we can read/write files with Unicode names."""