mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge pull request #3384 from alphagov/fix-cronitor-test-180344153
Fix flakey Cronitor test using caplog fixture
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -75,9 +74,8 @@ def test_cronitor_does_nothing_if_cronitor_not_enabled(notify_api, rmock):
|
|||||||
assert rmock.called is False
|
assert rmock.called is False
|
||||||
|
|
||||||
|
|
||||||
def test_cronitor_does_nothing_if_name_not_recognised(notify_api, rmock, caplog):
|
def test_cronitor_does_nothing_if_name_not_recognised(notify_api, rmock, mocker):
|
||||||
# ignore "INFO" log about task starting
|
mock_logger = mocker.patch('app.cronitor.current_app.logger')
|
||||||
caplog.set_level(logging.ERROR)
|
|
||||||
|
|
||||||
with set_config_values(notify_api, {
|
with set_config_values(notify_api, {
|
||||||
'CRONITOR_ENABLED': True,
|
'CRONITOR_ENABLED': True,
|
||||||
@@ -85,9 +83,10 @@ def test_cronitor_does_nothing_if_name_not_recognised(notify_api, rmock, caplog)
|
|||||||
}):
|
}):
|
||||||
assert successful_task() == 1
|
assert successful_task() == 1
|
||||||
|
|
||||||
error_log = caplog.records[0]
|
mock_logger.error.assert_called_with(
|
||||||
assert error_log.levelname == 'ERROR'
|
'Cronitor enabled but task_name hello not found in environment'
|
||||||
assert error_log.msg == 'Cronitor enabled but task_name hello not found in environment'
|
)
|
||||||
|
|
||||||
assert rmock.called is False
|
assert rmock.called is False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user