~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: Martin Pool
  • Date: 2006-03-10 06:29:53 UTC
  • mfrom: (1608 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060310062953-bc1c7ade75c89a7a
[merge] bzr.dev; pycurl not updated for readv yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
234
234
        self.assertRaises(FileExists, t.mkdir, 'dir_g')
235
235
 
236
236
        # Test get/put in sub-directories
237
 
        self.assertEqual(
 
237
        self.assertEqual(2, 
238
238
            t.put_multi([('dir_a/a', StringIO('contents of dir_a/a')),
239
 
                         ('dir_b/b', StringIO('contents of dir_b/b'))])
240
 
                        , 2)
 
239
                         ('dir_b/b', StringIO('contents of dir_b/b'))]))
241
240
        self.check_transport_contents('contents of dir_a/a', t, 'dir_a/a')
242
241
        self.check_transport_contents('contents of dir_b/b', t, 'dir_b/b')
243
242
 
271
270
        def simple_copy_files(transport_from, transport_to):
272
271
            files = ['a', 'b', 'c', 'd']
273
272
            self.build_tree(files, transport=transport_from)
274
 
            transport_from.copy_to(files, transport_to)
 
273
            self.assertEqual(4, transport_from.copy_to(files, transport_to))
275
274
            for f in files:
276
275
                self.check_transport_contents(transport_to.get(f).read(),
277
276
                                              transport_from, f)
329
328
                    t.append, 'a', 'add\nsome\nmore\ncontents\n')
330
329
            _append('a', StringIO('add\nsome\nmore\ncontents\n'))
331
330
        else:
332
 
            t.append('a', StringIO('add\nsome\nmore\ncontents\n'))
 
331
            self.assertEqual(20,
 
332
                t.append('a', StringIO('add\nsome\nmore\ncontents\n')))
333
333
 
334
334
        self.check_transport_contents(
335
335
            'diff\ncontents for\na\nadd\nsome\nmore\ncontents\n',
343
343
            _append('a', StringIO('and\nthen\nsome\nmore\n'))
344
344
            _append('b', StringIO('some\nmore\nfor\nb\n'))
345
345
        else:
346
 
            t.append_multi([('a', StringIO('and\nthen\nsome\nmore\n')),
347
 
                    ('b', StringIO('some\nmore\nfor\nb\n'))])
 
346
            self.assertEqual((43, 15), 
 
347
                t.append_multi([('a', StringIO('and\nthen\nsome\nmore\n')),
 
348
                                ('b', StringIO('some\nmore\nfor\nb\n'))]))
348
349
        self.check_transport_contents(
349
350
            'diff\ncontents for\na\n'
350
351
            'add\nsome\nmore\ncontents\n'
359
360
            _append('a', StringIO('a little bit more\n'))
360
361
            _append('b', StringIO('from an iterator\n'))
361
362
        else:
362
 
            t.append_multi(iter([('a', StringIO('a little bit more\n')),
363
 
                    ('b', StringIO('from an iterator\n'))]))
 
363
            self.assertEqual((62, 31),
 
364
                t.append_multi(iter([('a', StringIO('a little bit more\n')),
 
365
                                     ('b', StringIO('from an iterator\n'))])))
364
366
        self.check_transport_contents(
365
367
            'diff\ncontents for\na\n'
366
368
            'add\nsome\nmore\ncontents\n'
378
380
            _append('a', StringIO('some text in a\n'))
379
381
            _append('d', StringIO('missing file r\n'))
380
382
        else:
381
 
            t.append('c', StringIO('some text\nfor a missing file\n'))
382
 
            t.append_multi([('a', StringIO('some text in a\n')),
383
 
                            ('d', StringIO('missing file r\n'))])
 
383
            self.assertEqual(0,
 
384
                t.append('c', StringIO('some text\nfor a missing file\n')))
 
385
            self.assertEqual((80, 0),
 
386
                t.append_multi([('a', StringIO('some text in a\n')),
 
387
                                ('d', StringIO('missing file r\n'))]))
384
388
        self.check_transport_contents(
385
389
            'diff\ncontents for\na\n'
386
390
            'add\nsome\nmore\ncontents\n'
894
898
        # TODO make this consistent on all platforms:
895
899
        # self.assertRaises(LockError, transport.lock_read, 'lock')
896
900
        lock.unlock()
 
901
 
 
902
    def test_readv(self):
 
903
        transport = self.get_transport()
 
904
        if transport.is_readonly():
 
905
            file('a', 'w').write('0123456789')
 
906
        else:
 
907
            transport.put('a', StringIO('01234567890'))
 
908
 
 
909
        d = list(transport.readv('a', ((0, 1), (1, 1), (3, 2), (9, 1))))
 
910
        self.assertEqual(d[0], (0, '0'))
 
911
        self.assertEqual(d[1], (1, '1'))
 
912
        self.assertEqual(d[2], (3, '34'))
 
913
        self.assertEqual(d[3], (9, '9'))