/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

Fix ChrootTransportDecorator's abspath method to be consistent with its clone
method when dealing with relpaths that start with "/".

Show diffs side-by-side

added added

removed removed

Lines of Context:
303
303
        self.assertEqual('memory:///path/', transport.chroot_url)
304
304
        self.assertEqual('/B/', transport.chroot_relative)
305
305
 
306
 
    def test_append_file(self):
307
 
        transport = get_transport('chroot+memory:///foo/bar')
308
 
        self.assertRaises(PathNotChild, transport.append_file, '/foo', None)
309
 
 
310
 
    def test_append_bytes(self):
311
 
        transport = get_transport('chroot+memory:///foo/bar')
312
 
        self.assertRaises(PathNotChild, transport.append_bytes, '/foo', 'bytes')
 
306
    def test_abspath(self):
 
307
        # The abspath is always relative to the chroot_url.
 
308
        transport = get_transport('chroot+memory:///foo/bar/')
 
309
        self.assertEqual('chroot+memory:///foo/bar/', transport.abspath('/'))
 
310
 
 
311
        subdir_transport = transport.clone('subdir')
 
312
        self.assertEqual(
 
313
            'chroot+memory:///foo/bar/', subdir_transport.abspath('/'))
 
314
 
 
315
    def test_abspath_invalid(self):
 
316
        # You cannot have a url like "scheme:///chroot_root/..", which tries to
 
317
        # reference a location above chroot_url.
 
318
        transport = get_transport('chroot+memory:///foo/bar/')
 
319
 
 
320
        self.assertRaises(PathNotChild, transport.abspath, '..')
 
321
        self.assertRaises(PathNotChild, transport.abspath, '../..')
 
322
        self.assertRaises(PathNotChild, transport.abspath, 'foo/../..')
 
323
        self.assertRaises(PathNotChild, transport.abspath, '/..')
 
324
        self.assertRaises(PathNotChild, transport.abspath, '/foo/../..')
313
325
 
314
326
    def test_clone(self):
315
327
        transport = get_transport('chroot+memory:///foo/bar')
358
370
        self.assertEqual(
359
371
            'chroot+memory:///hello/subdir1/subdir2/', transport.base)
360
372
 
361
 
    def test_delete(self):
362
 
        transport = get_transport('chroot+memory:///foo/bar')
363
 
        self.assertRaises(PathNotChild, transport.delete, '/foo')
364
 
 
365
 
    def test_delete_tree(self):
366
 
        transport = get_transport('chroot+memory:///foo/bar')
367
 
        self.assertRaises(PathNotChild, transport.delete_tree, '/foo')
368
 
 
369
 
    def test_get(self):
370
 
        transport = get_transport('chroot+memory:///foo/bar')
371
 
        self.assertRaises(PathNotChild, transport.get, '/foo')
372
 
 
373
 
    def test_get_bytes(self):
374
 
        transport = get_transport('chroot+memory:///foo/bar')
375
 
        self.assertRaises(PathNotChild, transport.get_bytes, '/foo')
376
 
 
377
 
    def test_has(self):
378
 
        transport = get_transport('chroot+memory:///foo/bar')
379
 
        self.assertRaises(PathNotChild, transport.has, '/foo')
380
 
 
381
 
    def test_list_dir(self):
382
 
        transport = get_transport('chroot+memory:///foo/bar')
383
 
        self.assertRaises(PathNotChild, transport.list_dir, '/foo')
384
 
 
385
 
    def test_lock_read(self):
386
 
        transport = get_transport('chroot+memory:///foo/bar')
387
 
        self.assertRaises(PathNotChild, transport.lock_read, '/foo')
388
 
 
389
 
    def test_lock_write(self):
390
 
        transport = get_transport('chroot+memory:///foo/bar')
391
 
        self.assertRaises(PathNotChild, transport.lock_write, '/foo')
392
 
 
393
 
    def test_mkdir(self):
394
 
        transport = get_transport('chroot+memory:///foo/bar')
395
 
        self.assertRaises(PathNotChild, transport.mkdir, '/foo')
396
 
 
397
 
    def test_put_bytes(self):
398
 
        transport = get_transport('chroot+memory:///foo/bar')
399
 
        self.assertRaises(PathNotChild, transport.put_bytes, '/foo', 'bytes')
400
 
 
401
 
    def test_put_file(self):
402
 
        transport = get_transport('chroot+memory:///foo/bar')
403
 
        self.assertRaises(PathNotChild, transport.put_file, '/foo', None)
404
 
 
405
 
    def test_rename(self):
406
 
        transport = get_transport('chroot+memory:///foo/bar')
407
 
        self.assertRaises(PathNotChild, transport.rename, '/aaa', 'bbb')
408
 
        self.assertRaises(PathNotChild, transport.rename, 'ccc', '/d')
409
 
 
410
 
    def test_rmdir(self):
411
 
        transport = get_transport('chroot+memory:///foo/bar')
412
 
        self.assertRaises(PathNotChild, transport.rmdir, '/foo')
413
 
 
414
 
    def test_stat(self):
415
 
        transport = get_transport('chroot+memory:///foo/bar')
416
 
        self.assertRaises(PathNotChild, transport.stat, '/foo')
417
 
 
418
373
 
419
374
class FakeTransport(object):
420
375
    # XXX: FakeTransport copied from test_wsgi.py