303
303
self.assertEqual('memory:///path/', transport.chroot_url)
304
304
self.assertEqual('/B/', transport.chroot_relative)
306
def test_append_file(self):
307
transport = get_transport('chroot+memory:///foo/bar')
308
self.assertRaises(PathNotChild, transport.append_file, '/foo', None)
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('/'))
311
subdir_transport = transport.clone('subdir')
313
'chroot+memory:///foo/bar/', subdir_transport.abspath('/'))
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/')
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/../..')
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)
361
def test_delete(self):
362
transport = get_transport('chroot+memory:///foo/bar')
363
self.assertRaises(PathNotChild, transport.delete, '/foo')
365
def test_delete_tree(self):
366
transport = get_transport('chroot+memory:///foo/bar')
367
self.assertRaises(PathNotChild, transport.delete_tree, '/foo')
370
transport = get_transport('chroot+memory:///foo/bar')
371
self.assertRaises(PathNotChild, transport.get, '/foo')
373
def test_get_bytes(self):
374
transport = get_transport('chroot+memory:///foo/bar')
375
self.assertRaises(PathNotChild, transport.get_bytes, '/foo')
378
transport = get_transport('chroot+memory:///foo/bar')
379
self.assertRaises(PathNotChild, transport.has, '/foo')
381
def test_list_dir(self):
382
transport = get_transport('chroot+memory:///foo/bar')
383
self.assertRaises(PathNotChild, transport.list_dir, '/foo')
385
def test_lock_read(self):
386
transport = get_transport('chroot+memory:///foo/bar')
387
self.assertRaises(PathNotChild, transport.lock_read, '/foo')
389
def test_lock_write(self):
390
transport = get_transport('chroot+memory:///foo/bar')
391
self.assertRaises(PathNotChild, transport.lock_write, '/foo')
393
def test_mkdir(self):
394
transport = get_transport('chroot+memory:///foo/bar')
395
self.assertRaises(PathNotChild, transport.mkdir, '/foo')
397
def test_put_bytes(self):
398
transport = get_transport('chroot+memory:///foo/bar')
399
self.assertRaises(PathNotChild, transport.put_bytes, '/foo', 'bytes')
401
def test_put_file(self):
402
transport = get_transport('chroot+memory:///foo/bar')
403
self.assertRaises(PathNotChild, transport.put_file, '/foo', None)
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')
410
def test_rmdir(self):
411
transport = get_transport('chroot+memory:///foo/bar')
412
self.assertRaises(PathNotChild, transport.rmdir, '/foo')
415
transport = get_transport('chroot+memory:///foo/bar')
416
self.assertRaises(PathNotChild, transport.stat, '/foo')
419
374
class FakeTransport(object):
420
375
# XXX: FakeTransport copied from test_wsgi.py