def test_findln_by_time(): eq_(findln_by_time(pacemaker_unicode_log, time_before), 1) with open(evil_unicode_log, 'wb') as f: f.write(invalid_utf8) eq_(findln_by_time(evil_unicode_log, time_before), 1) os.remove(evil_unicode_log)
def test_findln_by_time(): assert findln_by_time(pacemaker_unicode_log, time_before) == 1 with open(evil_unicode_log, 'wb') as f: f.write(invalid_utf8) assert findln_by_time(evil_unicode_log, time_before) == 1 os.remove(evil_unicode_log)
def test_findln_by_time(): # time before log happen eq_(findln_by_time(pacemaker_log, time_before), 1) # time after log happen eq_(findln_by_time(pacemaker_log, time_after), 923) # time between log happen eq_(findln_by_time(pacemaker_log, time_between), 803)
def test_findln_by_time(): # time before log happen assert findln_by_time(pacemaker_log, time_before) == 1 # time after log happen assert findln_by_time(pacemaker_log, time_after) == 923 # time between log happen assert findln_by_time(pacemaker_log, time_between) == 803
def test_filter_lines(): begin_line = findln_by_time(pacemaker_log, time_before) end_line = findln_by_time(pacemaker_log, time_between) out1 = filter_lines(pacemaker_log, begin_line) out2 = filter_lines(pacemaker_log, begin_line, end_line) eq_(len(out1.split('\n')), 924) eq_(len(out2.split('\n')), 804)
def test_filter_lines(): begin_line = findln_by_time(pacemaker_log, time_before) end_line = findln_by_time(pacemaker_log, time_between) out1 = filter_lines(pacemaker_log, begin_line) out2 = filter_lines(pacemaker_log, begin_line, end_line) assert len(out1.split('\n')) == 924 assert len(out2.split('\n')) == 804
def test_findln_by_time(): target_time = "Apr 03 13:10" target_time_stamp = crmsh.utils.parse_to_timestamp(target_time) with open('pacemaker.log') as f: data = f.read() result_line = findln_by_time(data, target_time_stamp) result_line_stamp = line_time(data.split('\n'), result_line) assert result_line_stamp > target_time_stamp result_pre_line_stamp = line_time(data.split('\n'), result_line - 1) assert result_pre_line_stamp < target_time_stamp target_time = "Apr 03 11:01:19" target_time_stamp = crmsh.utils.parse_to_timestamp(target_time) result_line = findln_by_time(data, target_time_stamp) result_time = ' '.join(data.split('\n')[result_line - 1].split()[:3]) assert result_time == target_time