2016-11-10 19:30:09 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2016-09-20 22:51:11 +02:00
|
|
|
class CircleCiHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'circleci'
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/circleci?stream={stream}&api_key={api_key}"
|
2016-09-20 22:51:11 +02:00
|
|
|
FIXTURE_DIR_NAME = 'circleci'
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_circleci_build_in_success_status(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "RepoName"
|
|
|
|
expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch succeeded."
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('build_passed', expected_topic, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_circleci_build_in_failed_status(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "RepoName"
|
|
|
|
expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch failed."
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('build_failed', expected_topic, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_circleci_build_in_failed_status_when_previous_build_failed_too(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "RepoName"
|
|
|
|
expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch is still failing."
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('build_failed_when_previous_build_failed', expected_topic, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_circleci_build_in_success_status_when_previous_build_failed_too(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "RepoName"
|
|
|
|
expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch fixed."
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('build_passed_when_previous_build_failed', expected_topic, expected_message)
|