def test_final(capsys): check = Check() check.add_metric('Memory', 4500000, 'B', '4M:', '6M:', convert_metric=True) check.add_metric('CPU', 7, '%', '20:', '50:') with pytest.raises(SystemExit) as e: check.final() assert e.value.code == 2 assert capsys.readouterr().out == ( 'METRIC CRITICAL - Memory is 4.29MB, CPU is 7% | Memory=4500000B;4M:;6M: CPU=7%;20:;50:{0}' .format(os.linesep))
def test_final_per_second_UOM(capsys): check = Check() check.add_metric('Outbound Objects', 100, 'per_second', '50', '150', summary_precision=0, perf_data_precision=0) with pytest.raises(SystemExit) as e: check.final() assert e.value.code == 1 assert capsys.readouterr().out == ( "METRIC WARNING - Outbound Objects is 100/s | 'Outbound Objects'=100per_second;50;150{0}" .format(os.linesep))