mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
Almost all webhook tests use this helper, except a few webhooks that write to private streams. Being concise is important here, and the name `self.send_and_test_stream_message` always confused me, since it sounds you're sending a stream message, and it leaves out the webhook piece. We should consider renaming `send_and_test_private_message` to something like `check_webhook_private`, but I couldn't decide on a great name, and it's very rarely used. So for now I just made sure the docstrings of the two sibling functions reference each other.
28 lines
1.4 KiB
Python
28 lines
1.4 KiB
Python
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
class BuildbotHookTests(WebhookTestCase):
|
|
STREAM_NAME = "buildbot"
|
|
URL_TEMPLATE = "/api/v1/external/buildbot?api_key={api_key}&stream={stream}"
|
|
FIXTURE_DIR_NAME = "buildbot"
|
|
|
|
def test_build_started(self) -> None:
|
|
expected_topic = "buildbot-hello"
|
|
expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) for **runtests** started."
|
|
self.check_webhook("started", expected_topic, expected_message)
|
|
|
|
def test_build_success(self) -> None:
|
|
expected_topic = "buildbot-hello"
|
|
expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) (result: success) for **runtests** finished."
|
|
self.check_webhook("finished_success", expected_topic, expected_message)
|
|
|
|
def test_build_failure(self) -> None:
|
|
expected_topic = "general" # project key is empty
|
|
expected_message = "Build [#34](http://exampleurl.com/#builders/1/builds/34) (result: failure) for **runtests** finished."
|
|
self.check_webhook("finished_failure", expected_topic, expected_message)
|
|
|
|
def test_build_cancelled(self) -> None:
|
|
expected_topic = "zulip/zulip-zapier"
|
|
expected_message = "Build [#10434](https://ci.example.org/#builders/79/builds/307) (result: cancelled) for **AMD64 Ubuntu 18.04 Python 3** finished."
|
|
self.check_webhook("finished_cancelled", expected_topic, expected_message)
|