webhooks: Stop raising an exception if stream does not exist.

webhook-errors.log file is cluttered with Stream.DoesNotExist
errors, which hides the errors that we actually need to see. So,
since check_message already sends the bot_owner a PM if the webhook
bot tries to send a message to a non-existent stream, we can ignore
such exceptions.
This commit is contained in:
Eeshan Garg
2018-03-22 18:13:28 -02:30
committed by Tim Abbott
parent 4b8bd0bc3b
commit 538746fc65
6 changed files with 44 additions and 7 deletions

View File

@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from typing import Text
from zerver.lib.test_classes import WebhookTestCase
from zerver.models import get_system_bot
class HelloWorldHookTests(WebhookTestCase):
STREAM_NAME = 'test'
@@ -35,6 +37,16 @@ class HelloWorldHookTests(WebhookTestCase):
self.send_and_test_private_message('goodbye', expected_message=expected_message,
content_type="application/x-www-form-urlencoded")
def test_stream_error_pm_to_bot_owner(self) -> None:
# Note taht this is really just a test for check_send_webhook_message
self.STREAM_NAME = 'nonexistent'
self.url = self.build_webhook_url()
notification_bot = get_system_bot(settings.NOTIFICATION_BOT)
expected_message = "Hi there! We thought you'd like to know that your bot **Zulip Webhook Bot** just tried to send a message to stream `nonexistent`, but that stream does not yet exist. To create it, click the gear in the left-side stream list."
self.send_and_test_private_message('goodbye', expected_message=expected_message,
content_type='application/x-www-form-urlencoded',
sender=notification_bot)
def test_custom_topic(self) -> None:
# Note that this is really just a test for check_send_webhook_message
expected_subject = u"Custom Topic"