def test_generate_result_read_end_of_log_when_truncating(): logfile = StringIO('abcd1234') max_output_patch = patch('proccer.agent.max_output', 4) with dict_rusage_patch, get_result_patch, max_output_patch: res = _generate_result(0, logfile, None) eq_(res['output_truncated'], True) eq_(res['output'], '1234')
def test_generate_result_will_truncate(): logfile = MagicMock() logfile.tell.return_value = max_output + 1 logfile.read.return_value = '1234567890' with dict_rusage_patch, get_result_patch: res = _generate_result(0, logfile, None) eq_(res['output_truncated'], True) eq_(res['output'], '1234567890')
def test_generate_result_no_truncate_10(): logfile = MagicMock() logfile.tell.return_value = 10 logfile.read.return_value = '1234567890' with dict_rusage_patch, get_result_patch: res = _generate_result(0, logfile, None) eq_(res['output_truncated'], False) eq_(res['output'], '1234567890')
def test_generate_result_read_complete_log(): logfile = StringIO('abcd1234') with dict_rusage_patch, get_result_patch: res = _generate_result(0, logfile, None) eq_(res['output_truncated'], False) eq_(res['output'], 'abcd1234')