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:
Greg Price
2017-11-30 17:16:30 -08:00
committed by Steve Howell
parent a34c01780f
commit ca5c991994
3 changed files with 9 additions and 11 deletions

View File

@@ -73,12 +73,10 @@ class AdminNotifyHandlerTest(ZulipTestCase):
handler.emit(record)
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)
patched_publish.assert_called_once()
event = patched_publish.call_args[0][1]
self.assertIn("report", event)
return event["report"]
patched_notify.assert_called_once()
return patched_notify.call_args[0][0]
def test_long_exception_request(self) -> None:
"""A request with with no stack where report.getMessage() has newlines
@@ -167,13 +165,11 @@ class AdminNotifyHandlerTest(ZulipTestCase):
self.assertIn("stack_trace", report)
# 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")):
self.handler.emit(record)
# Test the STAGING_ERROR_NOTIFICATIONS code path
with self.settings(STAGING_ERROR_NOTIFICATIONS=True):
with patch('zerver.lib.error_notify.notify_server_error',
with self.settings(STAGING_ERROR_NOTIFICATIONS=False):
with patch('zerver.logging_handlers.queue_json_publish',
side_effect=Exception("queue error")):
self.handler.emit(record)

View File

@@ -53,6 +53,8 @@ EMBEDDED_BOTS_ENABLED = True
SAVE_FRONTEND_STACKTRACES = True
EVENT_LOGS_ENABLED = True
STAGING_ERROR_NOTIFICATIONS = True
SYSTEM_ONLY_REALMS = set() # type: Set[str]
USING_PGROONGA = True
# Flush cache after migration.

View File

@@ -1282,7 +1282,7 @@ LOGGING = {
'zulip_admins': {
'level': 'ERROR',
'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'],
'formatter': 'default'
},