2019-03-30 23:04:52 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2019-03-30 23:04:52 +01:00
|
|
|
class BuildbotHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "buildbot"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/buildbot?api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "buildbot"
|
2019-03-30 23:04:52 +01:00
|
|
|
|
|
|
|
def test_build_started(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "buildbot-hello"
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message = (
|
|
|
|
"Build [#33](http://exampleurl.com/#builders/1/builds/33) for **runtests** started."
|
|
|
|
)
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("started", expected_topic_name, expected_message)
|
2019-03-30 23:04:52 +01:00
|
|
|
|
|
|
|
def test_build_success(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "buildbot-hello"
|
2019-03-30 23:04:52 +01:00
|
|
|
expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) (result: success) for **runtests** finished."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("finished_success", expected_topic_name, expected_message)
|
2019-03-30 23:04:52 +01:00
|
|
|
|
|
|
|
def test_build_failure(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "general" # project key is empty
|
2019-03-30 23:04:52 +01:00
|
|
|
expected_message = "Build [#34](http://exampleurl.com/#builders/1/builds/34) (result: failure) for **runtests** finished."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("finished_failure", expected_topic_name, expected_message)
|
2019-06-01 00:58:50 +02:00
|
|
|
|
|
|
|
def test_build_cancelled(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "zulip/zulip-zapier"
|
2019-06-01 00:58:50 +02:00
|
|
|
expected_message = "Build [#10434](https://ci.example.org/#builders/79/builds/307) (result: cancelled) for **AMD64 Ubuntu 18.04 Python 3** finished."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("finished_cancelled", expected_topic_name, expected_message)
|