/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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
                           ConnectionError,
28
28
                           DependencyNotPresent,
29
29
                           UnsupportedProtocol,
 
30
                           PathNotChild,
30
31
                           )
31
32
from bzrlib.tests import TestCase, TestCaseInTempDir
32
33
from bzrlib.transport import (_CoalescedOffset,
235
236
        transport.append_bytes('foo', 'content')
236
237
        self.assertEquals(True, transport.has('foo'))
237
238
 
 
239
    def test_list_dir(self):
 
240
        transport = MemoryTransport()
 
241
        transport.put_bytes('foo', 'content')
 
242
        transport.mkdir('dir')
 
243
        transport.put_bytes('dir/subfoo', 'content')
 
244
        transport.put_bytes('dirlike', 'content')
 
245
 
 
246
        self.assertEquals(['dir', 'dirlike', 'foo'], sorted(transport.list_dir('.')))
 
247
        self.assertEquals(['subfoo'], sorted(transport.list_dir('dir')))
 
248
 
238
249
    def test_mkdir(self):
239
250
        transport = MemoryTransport()
240
251
        transport.mkdir('dir')
273
284
        self.assertEqual(7, transport.stat('foo').st_size)
274
285
        self.assertEqual(6, transport.stat('bar').st_size)
275
286
 
 
287
 
 
288
class ChrootDecoratorTransportTest(TestCase):
 
289
    """Chroot decoration specific tests."""
 
290
 
 
291
    def test_construct(self):
 
292
        from bzrlib.transport import chroot
 
293
        transport = chroot.ChrootTransportDecorator('chroot+memory:///pathA/')
 
294
        self.assertEqual('memory:///pathA/', transport.chroot_url)
 
295
 
 
296
        transport = chroot.ChrootTransportDecorator(
 
297
            'chroot+memory:///path/B', chroot='memory:///path/')
 
298
        self.assertEqual('memory:///path/', transport.chroot_url)
 
299
 
 
300
    def test_append_file(self):
 
301
        transport = get_transport('chroot+file:///foo/bar')
 
302
        self.assertRaises(PathNotChild, transport.append_file, '/foo', None)
 
303
 
 
304
    def test_append_bytes(self):
 
305
        transport = get_transport('chroot+file:///foo/bar')
 
306
        self.assertRaises(PathNotChild, transport.append_bytes, '/foo', 'bytes')
 
307
 
 
308
    def test_clone(self):
 
309
        transport = get_transport('chroot+file:///foo/bar')
 
310
        self.assertRaises(PathNotChild, transport.clone, '/foo')
 
311
 
 
312
    def test_delete(self):
 
313
        transport = get_transport('chroot+file:///foo/bar')
 
314
        self.assertRaises(PathNotChild, transport.delete, '/foo')
 
315
 
 
316
    def test_delete_tree(self):
 
317
        transport = get_transport('chroot+file:///foo/bar')
 
318
        self.assertRaises(PathNotChild, transport.delete_tree, '/foo')
 
319
 
 
320
    def test_get(self):
 
321
        transport = get_transport('chroot+file:///foo/bar')
 
322
        self.assertRaises(PathNotChild, transport.get, '/foo')
 
323
 
 
324
    def test_get_bytes(self):
 
325
        transport = get_transport('chroot+file:///foo/bar')
 
326
        self.assertRaises(PathNotChild, transport.get_bytes, '/foo')
 
327
 
 
328
    def test_has(self):
 
329
        transport = get_transport('chroot+file:///foo/bar')
 
330
        self.assertRaises(PathNotChild, transport.has, '/foo')
 
331
 
 
332
    def test_list_dir(self):
 
333
        transport = get_transport('chroot+file:///foo/bar')
 
334
        self.assertRaises(PathNotChild, transport.list_dir, '/foo')
 
335
 
 
336
    def test_lock_read(self):
 
337
        transport = get_transport('chroot+file:///foo/bar')
 
338
        self.assertRaises(PathNotChild, transport.lock_read, '/foo')
 
339
 
 
340
    def test_lock_write(self):
 
341
        transport = get_transport('chroot+file:///foo/bar')
 
342
        self.assertRaises(PathNotChild, transport.lock_write, '/foo')
 
343
 
 
344
    def test_mkdir(self):
 
345
        transport = get_transport('chroot+file:///foo/bar')
 
346
        self.assertRaises(PathNotChild, transport.mkdir, '/foo')
 
347
 
 
348
    def test_put_bytes(self):
 
349
        transport = get_transport('chroot+file:///foo/bar')
 
350
        self.assertRaises(PathNotChild, transport.put_bytes, '/foo', 'bytes')
 
351
 
 
352
    def test_put_file(self):
 
353
        transport = get_transport('chroot+file:///foo/bar')
 
354
        self.assertRaises(PathNotChild, transport.put_file, '/foo', None)
 
355
 
 
356
    def test_rename(self):
 
357
        transport = get_transport('chroot+file:///foo/bar')
 
358
        self.assertRaises(PathNotChild, transport.rename, '/aaa', 'bbb')
 
359
        self.assertRaises(PathNotChild, transport.rename, 'ccc', '/d')
 
360
 
 
361
    def test_rmdir(self):
 
362
        transport = get_transport('chroot+file:///foo/bar')
 
363
        self.assertRaises(PathNotChild, transport.rmdir, '/foo')
 
364
 
 
365
    def test_stat(self):
 
366
        transport = get_transport('chroot+file:///foo/bar')
 
367
        self.assertRaises(PathNotChild, transport.stat, '/foo')
 
368
 
276
369
        
277
370
class ReadonlyDecoratorTransportTest(TestCase):
278
371
    """Readonly decoration specific tests."""
286
379
        self.assertEqual(True, transport.is_readonly())
287
380
 
288
381
    def test_http_parameters(self):
 
382
        from bzrlib.tests.HttpServer import HttpServer
289
383
        import bzrlib.transport.readonly as readonly
290
 
        from bzrlib.transport.http import HttpServer
291
384
        # connect to . via http which is not listable
292
385
        server = HttpServer()
293
386
        server.setUp()
321
414
    def test_http_parameters(self):
322
415
        # the listable, should_cache and is_readonly parameters
323
416
        # are not changed by the fakenfs decorator
324
 
        from bzrlib.transport.http import HttpServer
 
417
        from bzrlib.tests.HttpServer import HttpServer
325
418
        # connect to . via http which is not listable
326
419
        server = HttpServer()
327
420
        server.setUp()