mirror of https://github.com/zulip/zulip.git
36 lines
1.9 KiB
Python
36 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
class SemaphoreHookTests(WebhookTestCase):
|
|
STREAM_NAME = 'semaphore'
|
|
URL_TEMPLATE = "/api/v1/external/semaphore?stream={stream}&api_key={api_key}"
|
|
|
|
# Messages are generated by Semaphore on git push. The subject lines below
|
|
# contain information on the repo and branch, and the message has links and
|
|
# details about the build, deploy, server, author, and commit
|
|
|
|
def test_semaphore_build(self) -> None:
|
|
expected_topic = u"knighthood/master" # repo/branch
|
|
expected_message = """
|
|
[Build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314) passed:
|
|
* **Commit**: [a490b8d: Create user account for Rocinante](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf)
|
|
* **Author**: don@lamancha.com
|
|
""".strip()
|
|
self.send_and_test_stream_message('build', expected_topic, expected_message,
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
def test_semaphore_deploy(self) -> None:
|
|
expected_topic = u"knighthood/master"
|
|
expected_message = """
|
|
[Deploy 17](https://semaphoreci.com/donquixote/knighthood/servers/lamancha-271/deploys/17) of [build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314) passed:
|
|
* **Commit**: [a490b8d: Create user account for Rocinante](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf)
|
|
* **Author**: don@lamancha.com
|
|
* **Server**: lamancha-271
|
|
""".strip()
|
|
self.send_and_test_stream_message('deploy', expected_topic, expected_message,
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
def get_body(self, fixture_name: str) -> str:
|
|
return self.webhook_fixture_data("semaphore", fixture_name, file_type="json")
|