mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
webhooks: Migrate to UnexpectedWebhookEventType.
This improves test coverage for a lot of our webhooks that relied on ad-hoc methods to handle unexpected event types. Note that I have deliberately skipped github_legacy, it isn't advertised and is officially deprecated. Also, I have refrained from making further changes to Trello, I believe further improvements to test coverage should be covered in separate per-webhook commits/PRs.
This commit is contained in:
@@ -7,7 +7,8 @@ from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.lib.webhooks.common import check_send_webhook_message, \
|
||||
UnexpectedWebhookEventType
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.models import Stream, UserProfile
|
||||
|
||||
@@ -30,7 +31,7 @@ def api_newrelic_webhook(request: HttpRequest, user_profile: UserProfile,
|
||||
|
||||
%(changelog)s""" % (deployment)
|
||||
else:
|
||||
return json_error(_("Unknown webhook request"))
|
||||
raise UnexpectedWebhookEventType('New Relic', 'Unknown Event Type')
|
||||
|
||||
check_send_webhook_message(request, user_profile, subject, content)
|
||||
return json_success()
|
||||
|
||||
Reference in New Issue
Block a user