~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-05 21:20:24 UTC
  • mto: (1946.2.8 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1988.
  • Revision ID: john@arbash-meinel.com-20060905212024-39f58d0f5acd74a4
Deprecate 'Transport.append' in favor of Transport.append_file or Transport.append_bytes

Show diffs side-by-side

added added

removed removed

Lines of Context:
385
385
        t = self.get_transport()
386
386
 
387
387
        if t.is_readonly():
 
388
            return
 
389
        t.put_bytes('a', 'diff\ncontents for\na\n')
 
390
        t.put_bytes('b', 'contents\nfor b\n')
 
391
 
 
392
        deprecation_msg = '%s.%s.%s was deprecated in version 0.11.' % (
 
393
            t.append.im_class.__module__, t.append.im_class.__name__,
 
394
            t.append.__name__)
 
395
        self.assertEqual(20, self.callDeprecated([deprecation_msg],
 
396
            t.append, 'a', StringIO('add\nsome\nmore\ncontents\n')))
 
397
 
 
398
        self.check_transport_contents(
 
399
            'diff\ncontents for\na\nadd\nsome\nmore\ncontents\n',
 
400
            t, 'a')
 
401
 
 
402
        # And we can create new files, too
 
403
        self.assertEqual(0, self.callDeprecated([deprecation_msg],
 
404
            t.append, 'c', StringIO('some text\nfor a missing file\n')))
 
405
        self.check_transport_contents('some text\nfor a missing file\n',
 
406
                                      t, 'c')
 
407
    def test_append_file(self):
 
408
        t = self.get_transport()
 
409
 
 
410
        if t.is_readonly():
388
411
            self.assertRaises(TransportNotPossible,
389
 
                    t.append, 'a', 'add\nsome\nmore\ncontents\n')
 
412
                    t.append_file, 'a', 'add\nsome\nmore\ncontents\n')
390
413
            return
391
414
        t.put_bytes('a', 'diff\ncontents for\na\n')
392
415
        t.put_bytes('b', 'contents\nfor b\n')
393
416
 
394
417
        self.assertEqual(20,
395
 
            t.append('a', StringIO('add\nsome\nmore\ncontents\n')))
 
418
            t.append_file('a', StringIO('add\nsome\nmore\ncontents\n')))
396
419
 
397
420
        self.check_transport_contents(
398
421
            'diff\ncontents for\na\nadd\nsome\nmore\ncontents\n',
400
423
 
401
424
        # a file with no parent should fail..
402
425
        self.assertRaises(NoSuchFile,
403
 
                          t.append, 'missing/path', StringIO('content'))
 
426
                          t.append_file, 'missing/path', StringIO('content'))
404
427
 
405
428
        # And we can create new files, too
406
429
        self.assertEqual(0,
407
 
            t.append('c', StringIO('some text\nfor a missing file\n')))
 
430
            t.append_file('c', StringIO('some text\nfor a missing file\n')))
408
431
        self.check_transport_contents('some text\nfor a missing file\n',
409
432
                                      t, 'c')
410
433
 
481
504
            t, 'a')
482
505
        self.check_transport_contents('missing file r\n', t, 'd')
483
506
 
484
 
    def test_append_mode(self):
 
507
    def test_append_file_mode(self):
485
508
        """Check that append accepts a mode parameter"""
486
509
        # check append accepts a mode
487
510
        t = self.get_transport()
488
511
        if t.is_readonly():
489
512
            self.assertRaises(TransportNotPossible,
490
 
                t.append, 'f', StringIO('f'), mode=None)
 
513
                t.append_file, 'f', StringIO('f'), mode=None)
491
514
            return
492
 
        t.append('f', StringIO('f'), mode=None)
 
515
        t.append_file('f', StringIO('f'), mode=None)
493
516
        
494
517
    def test_append_bytes_mode(self):
495
518
        # check append_bytes accepts a mode