~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-25 22:19:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1963.
  • Revision ID: john@arbash-meinel.com-20060825221948-b14fa1054682bab2
David Allouche: Make transports return escaped paths

Show diffs side-by-side

added added

removed removed

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