486
486
message = "Data not equal. Expected %d bytes, received %d."
487
487
self.fail(message % (len(response_data), self.test_data_len))
489
def test_report_activity(self):
491
def log_activity(length, direction):
492
activity.append((length, direction))
493
from_file = StringIO(self.test_data)
495
pumpfile(from_file, to_file, buff_size=500,
496
report_activity=log_activity, direction='read')
497
self.assertEqual([(500, 'read'), (500, 'read'), (500, 'read'),
498
(36, 'read')], activity)
500
from_file = StringIO(self.test_data)
503
pumpfile(from_file, to_file, buff_size=500,
504
report_activity=log_activity, direction='write')
505
self.assertEqual([(500, 'write'), (500, 'write'), (500, 'write'),
506
(36, 'write')], activity)
508
# And with a limited amount of data
509
from_file = StringIO(self.test_data)
512
pumpfile(from_file, to_file, buff_size=500, read_length=1028,
513
report_activity=log_activity, direction='read')
514
self.assertEqual([(500, 'read'), (500, 'read'), (28, 'read')], activity)
490
518
class TestPumpStringFile(TestCase):