~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

More tests for abspath and clone behaviour

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
        self.check_transport_contents('another contents\nfor d\n', t, 'd')
143
143
 
144
144
        self.assertRaises(NoSuchFile,
145
 
                          t.put, 'path/doesnt/exist/c', 'contents')
 
145
                          t.put, 'path/doesnt/exist/c', StringIO('contents'))
146
146
 
147
147
    def test_put_permissions(self):
148
148
        t = self.get_transport()
543
543
        t.mkdir('adir')
544
544
        t.mkdir('adir/bdir')
545
545
        t.rmdir('adir/bdir')
546
 
        self.assertRaises(NoSuchFile, t.stat, 'adir/bdir')
 
546
        self.assertFalse(t.has('adir/bdir'))
547
547
        t.rmdir('adir')
548
 
        self.assertRaises(NoSuchFile, t.stat, 'adir')
 
548
        self.assertFalse(t.has('adir'))
549
549
 
550
550
    def test_rmdir_not_empty(self):
551
551
        """Deleting a non-empty directory raises an exception
826
826
        self.failUnless(t2.has('d'))
827
827
        self.failUnless(t3.has('b/d'))
828
828
 
 
829
    def test_clone_to_root(self):
 
830
        orig_transport = self.get_transport()
 
831
        # Repeatedly go up to a parent directory until we're at the root
 
832
        # directory of this transport
 
833
        root_transport = orig_transport
 
834
        while root_transport.clone("..").base != root_transport.base:
 
835
            root_transport = root_transport.clone("..")
 
836
 
 
837
        # Cloning to "/" should take us to exactly the same location.
 
838
        self.assertEqual(root_transport.base, orig_transport.clone("/").base)
 
839
 
 
840
    def test_base_url(self):
 
841
        t = self.get_transport()
 
842
        self.assertEqual('/', t.base[-1])
 
843
 
829
844
    def test_relpath(self):
830
845
        t = self.get_transport()
831
846
        self.assertEqual('', t.relpath(t.base))
859
874
        self.assertEqual(transport.base + 'relpath',
860
875
                         transport.abspath('relpath'))
861
876
 
 
877
        # This should work without raising an error.
 
878
        transport.abspath("/")
 
879
 
 
880
        # the abspath of "/" and "/foo/.." should result in the same location
 
881
        self.assertEqual(transport.abspath("/"), transport.abspath("/foo/.."))
 
882
 
862
883
    def test_local_abspath(self):
863
884
        transport = self.get_transport()
864
885
        try:
1038
1059
        self.assertEqual(d[1], (9, '9'))
1039
1060
        self.assertEqual(d[2], (0, '0'))
1040
1061
        self.assertEqual(d[3], (3, '34'))
 
1062