mirror of https://github.com/zulip/zulip.git
test-backend: Raise zerver/views/report.py test coverage to 100%.
This commit is contained in:
parent
49687272a9
commit
7ed10da4ad
|
@ -97,7 +97,6 @@ not_yet_fully_covered = {
|
||||||
# Getting views file coverage to 100% is a major project goal
|
# Getting views file coverage to 100% is a major project goal
|
||||||
'zerver/views/auth.py',
|
'zerver/views/auth.py',
|
||||||
'zerver/views/messages.py',
|
'zerver/views/messages.py',
|
||||||
'zerver/views/report.py',
|
|
||||||
'zerver/views/home.py',
|
'zerver/views/home.py',
|
||||||
'zerver/views/registration.py',
|
'zerver/views/registration.py',
|
||||||
'zerver/views/events_register.py',
|
'zerver/views/events_register.py',
|
||||||
|
|
|
@ -143,3 +143,14 @@ class TestReport(ZulipTestCase):
|
||||||
with self.settings(BROWSER_ERROR_REPORTING=False):
|
with self.settings(BROWSER_ERROR_REPORTING=False):
|
||||||
result = self.client_post("/json/report_error", params)
|
result = self.client_post("/json/report_error", params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
|
||||||
|
# If js_source_map is present, then the stack trace should be annotated.
|
||||||
|
# DEBUG=False and TEST_SUITE=False are necessary to ensure that
|
||||||
|
# js_source_map actually gets instantiated.
|
||||||
|
with \
|
||||||
|
self.settings(DEBUG=False, TEST_SUITE=False), \
|
||||||
|
mock.patch('zerver.lib.unminify.SourceMap.annotate_stacktrace') as annotate:
|
||||||
|
result = self.client_post("/json/report_error", params)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
# fix_params (see above) adds quotes when JSON encoding.
|
||||||
|
annotate.assert_called_once_with('"trace"')
|
||||||
|
|
|
@ -18,11 +18,16 @@ from typing import Optional, Text
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Read the source map information for decoding JavaScript backtraces
|
|
||||||
js_source_map = None
|
js_source_map = None
|
||||||
if not (settings.DEBUG or settings.TEST_SUITE):
|
|
||||||
js_source_map = SourceMap(os.path.join(
|
# Read the source map information for decoding JavaScript backtraces.
|
||||||
settings.DEPLOY_ROOT, 'prod-static/source-map'))
|
def get_js_source_map():
|
||||||
|
# type: () -> Optional[SourceMap]
|
||||||
|
global js_source_map
|
||||||
|
if not js_source_map and not (settings.DEBUG or settings.TEST_SUITE):
|
||||||
|
js_source_map = SourceMap(os.path.join(
|
||||||
|
settings.DEPLOY_ROOT, 'prod-static/source-map'))
|
||||||
|
return js_source_map
|
||||||
|
|
||||||
@authenticated_json_post_view
|
@authenticated_json_post_view
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -85,6 +90,7 @@ def json_report_error(request, user_profile, message=REQ(), stacktrace=REQ(),
|
||||||
if not settings.BROWSER_ERROR_REPORTING:
|
if not settings.BROWSER_ERROR_REPORTING:
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
||||||
|
js_source_map = get_js_source_map()
|
||||||
if js_source_map:
|
if js_source_map:
|
||||||
stacktrace = js_source_map.annotate_stacktrace(stacktrace)
|
stacktrace = js_source_map.annotate_stacktrace(stacktrace)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue