コード例 #1
0
 def test_run_ok(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch("check_aws_limits.CheckAWSLimits.check_limits") as mock_check:
         mock_check.return_value = ([], [])
         cls.run(verbose=True)
     assert mock_check.mock_calls == [call.check_limits(verbose=True)]
     out, err = capsys.readouterr()
     assert out == "All limits are within thresholds.\n"
     assert err == ""
コード例 #2
0
 def test_run_ok(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch('check_aws_limits.CheckAWSLimits.check_limits') as mock_check:
         mock_check.return_value = ([], [])
         cls.run(verbose=True)
     assert mock_check.mock_calls == [call.check_limits(verbose=True)]
     out, err = capsys.readouterr()
     assert out == "All limits are within thresholds.\n"
     assert err == ''
コード例 #3
0
 def test_run_warn(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch(
             'check_aws_limits.CheckAWSLimits.check_limits') as mock_check:
         mock_check.return_value = (['warn1', 'warn2'], [])
         cls.run()
     assert mock_check.mock_calls == [call.check_limits(verbose=False)]
     out, err = capsys.readouterr()
     assert out == "\nWARNING:\n\n" \
         "warn1\n" \
         "warn2\n" \
         "\n0 limit(s) above CRITICAL threshold; 2 limit(s) above WARNING threshold\n"
     assert err == ''
コード例 #4
0
 def test_run_warn(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch("check_aws_limits.CheckAWSLimits.check_limits") as mock_check:
         mock_check.return_value = (["warn1", "warn2"], [])
         cls.run()
     assert mock_check.mock_calls == [call.check_limits(verbose=False)]
     out, err = capsys.readouterr()
     assert (
         out == "\nWARNING:\n\n"
         "warn1\n"
         "warn2\n"
         "\n0 limit(s) above CRITICAL threshold; 2 limit(s) above WARNING threshold\n"
     )
     assert err == ""
コード例 #5
0
 def test_run_crit(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch(
             'check_aws_limits.CheckAWSLimits.check_limits') as mock_check:
         mock_check.return_value = ([], ['crit1'])
         with pytest.raises(SystemExit) as excinfo:
             cls.run(error_on_warning=True)
         assert excinfo.value.code == 1
     assert mock_check.mock_calls == [call.check_limits(verbose=False)]
     out, err = capsys.readouterr()
     assert out == "\nCRITICAL:\n\n" \
         "crit1\n" \
         "\n1 limit(s) above CRITICAL threshold; 0 limit(s) above WARNING threshold\n"
     assert err == ''
コード例 #6
0
 def test_run_crit(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch("check_aws_limits.CheckAWSLimits.check_limits") as mock_check:
         mock_check.return_value = ([], ["crit1"])
         with pytest.raises(SystemExit) as excinfo:
             cls.run(error_on_warning=True)
         assert excinfo.value.code == 1
     assert mock_check.mock_calls == [call.check_limits(verbose=False)]
     out, err = capsys.readouterr()
     assert (
         out == "\nCRITICAL:\n\n"
         "crit1\n"
         "\n1 limit(s) above CRITICAL threshold; 0 limit(s) above WARNING threshold\n"
     )
     assert err == ""
コード例 #7
0
 def test_run_warn_error_on_warning(self, capsys):
     cls = check_aws_limits.CheckAWSLimits()
     with patch('check_aws_limits.CheckAWSLimits.check_limits') as mock_check:
         mock_check.return_value = (
             ['warn1', 'warn2'],
             []
         )
         with pytest.raises(SystemExit) as excinfo:
             cls.run(error_on_warning=True)
         assert excinfo.value.code == 1
     assert mock_check.mock_calls == [call.check_limits(verbose=False)]
     out, err = capsys.readouterr()
     assert out == "\nWARNING:\n\n" \
         "warn1\n" \
         "warn2\n" \
         "\n0 limit(s) above CRITICAL threshold; 2 limit(s) above WARNING threshold\n"
     assert err == ''