mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
errors: Simplify manual testing of error emails.
There are two different things you need to patch in order to get error emails (at `/emails`) in dev. Flip one of them in dev all the time, and make the comment on the other a bit more explicit.
This commit is contained in:
@@ -73,12 +73,10 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||||||
handler.emit(record)
|
handler.emit(record)
|
||||||
|
|
||||||
def run_handler(self, record: logging.LogRecord) -> Dict[str, Any]:
|
def run_handler(self, record: logging.LogRecord) -> Dict[str, Any]:
|
||||||
with patch('zerver.logging_handlers.queue_json_publish') as patched_publish:
|
with patch('zerver.lib.error_notify.notify_server_error') as patched_notify:
|
||||||
self.handler.emit(record)
|
self.handler.emit(record)
|
||||||
patched_publish.assert_called_once()
|
patched_notify.assert_called_once()
|
||||||
event = patched_publish.call_args[0][1]
|
return patched_notify.call_args[0][0]
|
||||||
self.assertIn("report", event)
|
|
||||||
return event["report"]
|
|
||||||
|
|
||||||
def test_long_exception_request(self) -> None:
|
def test_long_exception_request(self) -> None:
|
||||||
"""A request with with no stack where report.getMessage() has newlines
|
"""A request with with no stack where report.getMessage() has newlines
|
||||||
@@ -167,13 +165,11 @@ class AdminNotifyHandlerTest(ZulipTestCase):
|
|||||||
self.assertIn("stack_trace", report)
|
self.assertIn("stack_trace", report)
|
||||||
|
|
||||||
# Test the catch-all exception handler doesn't throw
|
# Test the catch-all exception handler doesn't throw
|
||||||
with patch('zerver.logging_handlers.queue_json_publish',
|
with patch('zerver.lib.error_notify.notify_server_error',
|
||||||
side_effect=Exception("queue error")):
|
side_effect=Exception("queue error")):
|
||||||
self.handler.emit(record)
|
self.handler.emit(record)
|
||||||
|
with self.settings(STAGING_ERROR_NOTIFICATIONS=False):
|
||||||
# Test the STAGING_ERROR_NOTIFICATIONS code path
|
with patch('zerver.logging_handlers.queue_json_publish',
|
||||||
with self.settings(STAGING_ERROR_NOTIFICATIONS=True):
|
|
||||||
with patch('zerver.lib.error_notify.notify_server_error',
|
|
||||||
side_effect=Exception("queue error")):
|
side_effect=Exception("queue error")):
|
||||||
self.handler.emit(record)
|
self.handler.emit(record)
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ EMBEDDED_BOTS_ENABLED = True
|
|||||||
|
|
||||||
SAVE_FRONTEND_STACKTRACES = True
|
SAVE_FRONTEND_STACKTRACES = True
|
||||||
EVENT_LOGS_ENABLED = True
|
EVENT_LOGS_ENABLED = True
|
||||||
|
STAGING_ERROR_NOTIFICATIONS = True
|
||||||
|
|
||||||
SYSTEM_ONLY_REALMS = set() # type: Set[str]
|
SYSTEM_ONLY_REALMS = set() # type: Set[str]
|
||||||
USING_PGROONGA = True
|
USING_PGROONGA = True
|
||||||
# Flush cache after migration.
|
# Flush cache after migration.
|
||||||
|
|||||||
@@ -1282,7 +1282,7 @@ LOGGING = {
|
|||||||
'zulip_admins': {
|
'zulip_admins': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'class': 'zerver.logging_handlers.AdminNotifyHandler',
|
'class': 'zerver.logging_handlers.AdminNotifyHandler',
|
||||||
# For testing the handler delete the next line
|
# For manual testing of this handler, delete the `filters` line.
|
||||||
'filters': ['ZulipLimiter', 'require_debug_false', 'require_really_deployed'],
|
'filters': ['ZulipLimiter', 'require_debug_false', 'require_really_deployed'],
|
||||||
'formatter': 'default'
|
'formatter': 'default'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user