Skip to content

Instantly share code, notes, and snippets.

@cpina
Created February 14, 2024 08:38
Show Gist options
  • Save cpina/8800b9e62af9bf2aee2adf4985d0e75f to your computer and use it in GitHub Desktop.
Save cpina/8800b9e62af9bf2aee2adf4985d0e75f to your computer and use it in GitHub Desktop.
carles@pinux:[v1.12.0]~/git/simplemonitor$ TZ=GMT+12 pytest
============================================================================= test session starts =============================================================================
platform linux -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0+repack
PySide2 5.15.8 -- Qt runtime 5.15.8 -- Qt compiled 5.15.8
rootdir: /home/carles/git/simplemonitor
plugins: mock-3.12.0, socket-0.6.0, anyio-3.6.2, cov-4.0.0, qt-4.2.0+repack, requests-mock-1.9.3, xvfb-2.0.0
collected 160 items
tests/test_alerter.py .........F............F......FF.F.F.................................... [ 44%]
tests/test_envconfig.py .. [ 45%]
tests/test_fortysixelks.py . [ 46%]
tests/test_host.py .......... [ 52%]
tests/test_htmllogger.py . [ 53%]
tests/test_logger.py ......................... [ 68%]
tests/test_main.py ........... [ 75%]
tests/test_monitor.py ............... [ 85%]
tests/test_network_new.py .. [ 86%]
tests/test_service.py ... [ 88%]
tests/test_util.py ................... [100%]
================================================================================== FAILURES ===================================================================================
_______________________________________________________________________ TestAlerter.test_allowed_today ________________________________________________________________________
self = <test_alerter.TestAlerter testMethod=test_allowed_today>
@freeze_time("2020-03-10")
def test_allowed_today(self):
a = alerter.Alerter({"days": "1"})
> self.assertTrue(a._allowed_today())
E AssertionError: False is not true
tests/test_alerter.py:155: AssertionError
_____________________________________________________________________ TestAlerter.test_not_allowed_today ______________________________________________________________________
self = <test_alerter.TestAlerter testMethod=test_not_allowed_today>
@freeze_time("2020-03-10") # a Tuesday
def test_not_allowed_today(self):
a = alerter.Alerter({"days": "0,2,3,4,5,6"})
> self.assertFalse(a._allowed_today())
E AssertionError: True is not false
tests/test_alerter.py:143: AssertionError
____________________________________________________________________ TestAlerter.test_should_alert_catchup ____________________________________________________________________
self = <test_alerter.TestAlerter testMethod=test_should_alert_catchup>
def test_should_alert_catchup(self):
config = {
"delay": 1,
"times_type": "only",
"time_lower": "10:00",
"time_upper": "11:00",
}
a = alerter.Alerter(config)
a.support_catchup = True
m = monitor.MonitorFail("fail", {})
m.run_test()
with freeze_time("2020-03-10 09:00"):
self.assertEqual(a.should_alert(m), alerter.AlertType.NONE)
self.assertEqual(a._ooh_failures, ["fail"])
with freeze_time("2020-03-10 10:30"):
> self.assertEqual(a.should_alert(m), alerter.AlertType.CATCHUP)
E AssertionError: <AlertType.NONE: 'none'> != <AlertType.CATCHUP: 'catchup'>
tests/test_alerter.py:313: AssertionError
_____________________________________________________________________ TestAlerter.test_should_alert_limit _____________________________________________________________________
self = <test_alerter.TestAlerter testMethod=test_should_alert_limit>
def test_should_alert_limit(self):
config = {
"times_type": "only",
"time_lower": "10:00",
"time_upper": "11:00",
"limit": 2,
}
a = alerter.Alerter(config)
m = monitor.MonitorFail("fail", {})
m.run_test()
with freeze_time("2020-03-10 10:30"):
self.assertEqual(a.should_alert(m), alerter.AlertType.NONE)
self.assertEqual(a._ooh_failures, [])
m.run_test()
> self.assertEqual(a.should_alert(m), alerter.AlertType.FAILURE)
E AssertionError: <AlertType.NONE: 'none'> != <AlertType.FAILURE: 'failure'>
tests/test_alerter.py:266: AssertionError
__________________________________________________________________ TestAlerter.test_should_alert_no_catchup ___________________________________________________________________
self = <test_alerter.TestAlerter testMethod=test_should_alert_no_catchup>
def test_should_alert_no_catchup(self):
config = {
"delay": 1,
"times_type": "only",
"time_lower": "10:00",
"time_upper": "11:00",
}
a = alerter.Alerter(config)
m = monitor.MonitorFail("fail", {})
m.run_test()
with freeze_time("2020-03-10 09:00"):
self.assertEqual(a.should_alert(m), alerter.AlertType.NONE)
self.assertEqual(a._ooh_failures, ["fail"])
with freeze_time("2020-03-10 10:30"):
> self.assertEqual(a.should_alert(m), alerter.AlertType.FAILURE)
E AssertionError: <AlertType.NONE: 'none'> != <AlertType.FAILURE: 'failure'>
tests/test_alerter.py:331: AssertionError
______________________________________________________________________ TestAlerter.test_should_alert_ooh ______________________________________________________________________
self = <test_alerter.TestAlerter testMethod=test_should_alert_ooh>
def test_should_alert_ooh(self):
config = {"times_type": "only", "time_lower": "10:00", "time_upper": "11:00"}
a = alerter.Alerter(config)
m = monitor.MonitorFail("fail", {})
m.run_test()
with freeze_time("2020-03-10 10:30"):
> self.assertEqual(a.should_alert(m), alerter.AlertType.FAILURE)
E AssertionError: <AlertType.NONE: 'none'> != <AlertType.FAILURE: 'failure'>
tests/test_alerter.py:248: AssertionError
============================================================================== warnings summary ===============================================================================
../../../../usr/lib/python3/dist-packages/shiboken2/files.dir/shibokensupport/feature.py:139
/usr/lib/python3/dist-packages/shiboken2/files.dir/shibokensupport/feature.py:139: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
return original_import(name, *args, **kwargs)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================== short test summary info ===========================================================================
FAILED tests/test_alerter.py::TestAlerter::test_allowed_today - AssertionError: False is not true
FAILED tests/test_alerter.py::TestAlerter::test_not_allowed_today - AssertionError: True is not false
FAILED tests/test_alerter.py::TestAlerter::test_should_alert_catchup - AssertionError: <AlertType.NONE: 'none'> != <AlertType.CATCHUP: 'catchup'>
FAILED tests/test_alerter.py::TestAlerter::test_should_alert_limit - AssertionError: <AlertType.NONE: 'none'> != <AlertType.FAILURE: 'failure'>
FAILED tests/test_alerter.py::TestAlerter::test_should_alert_no_catchup - AssertionError: <AlertType.NONE: 'none'> != <AlertType.FAILURE: 'failure'>
FAILED tests/test_alerter.py::TestAlerter::test_should_alert_ooh - AssertionError: <AlertType.NONE: 'none'> != <AlertType.FAILURE: 'failure'>
================================================================== 6 failed, 154 passed, 1 warning in 4.03s ===================================================================
carles@pinux:[v1.12.0]~/git/simplemonitor$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment