385
385
t = self.get_transport()
387
387
if t.is_readonly():
389
t.put_bytes('a', 'diff\ncontents for\na\n')
390
t.put_bytes('b', 'contents\nfor b\n')
392
deprecation_msg = '%s.%s.%s was deprecated in version 0.11.' % (
393
t.append.im_class.__module__, t.append.im_class.__name__,
395
self.assertEqual(20, self.callDeprecated([deprecation_msg],
396
t.append, 'a', StringIO('add\nsome\nmore\ncontents\n')))
398
self.check_transport_contents(
399
'diff\ncontents for\na\nadd\nsome\nmore\ncontents\n',
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',
407
def test_append_file(self):
408
t = self.get_transport()
388
411
self.assertRaises(TransportNotPossible,
389
t.append, 'a', 'add\nsome\nmore\ncontents\n')
412
t.append_file, 'a', 'add\nsome\nmore\ncontents\n')
391
414
t.put_bytes('a', 'diff\ncontents for\na\n')
392
415
t.put_bytes('b', 'contents\nfor b\n')
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')))
397
420
self.check_transport_contents(
398
421
'diff\ncontents for\na\nadd\nsome\nmore\ncontents\n',
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'))
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',
482
505
self.check_transport_contents('missing file r\n', t, 'd')
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)
492
t.append('f', StringIO('f'), mode=None)
515
t.append_file('f', StringIO('f'), mode=None)
494
517
def test_append_bytes_mode(self):
495
518
# check append_bytes accepts a mode