2016-12-31 18:06:29 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
class SolanoHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'solano labs'
|
2018-03-16 22:53:50 +01:00
|
|
|
URL_TEMPLATE = u"/api/v1/external/solano?api_key={api_key}&stream={stream}"
|
2016-12-31 18:06:29 +01:00
|
|
|
FIXTURE_DIR_NAME = 'solano'
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_solano_message_001(self) -> None:
|
2016-12-31 18:06:29 +01:00
|
|
|
"""
|
|
|
|
Build notifications are generated by Solano Labs after build completes.
|
|
|
|
"""
|
|
|
|
expected_topic = u'build update'
|
2019-04-18 23:25:03 +02:00
|
|
|
expected_message = """
|
|
|
|
Build update (see [build log](https://ci.solanolabs.com:443/reports/3316175)):
|
|
|
|
* **Author**: solano-ci[bot]@users.noreply.github.com
|
|
|
|
* **Commit**: [5f43840](github.com/fazerlicourice7/solano/commit/5f438401eb7cc7268cbc28438bfa70bb99f48a03)
|
|
|
|
* **Status**: failed :thumbs_down:
|
|
|
|
""".strip()
|
2016-12-31 18:06:29 +01:00
|
|
|
|
|
|
|
self.send_and_test_stream_message('build_001', expected_topic, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_solano_message_002(self) -> None:
|
2016-12-31 18:06:29 +01:00
|
|
|
"""
|
|
|
|
Build notifications are generated by Solano Labs after build completes.
|
|
|
|
"""
|
|
|
|
expected_topic = u'build update'
|
2019-04-18 23:25:03 +02:00
|
|
|
expected_message = """
|
|
|
|
Build update (see [build log](https://ci.solanolabs.com:443/reports/3316723)):
|
|
|
|
* **Author**: Unknown
|
|
|
|
* **Commit**: [5d0b92e](bitbucket.org/fazerlicourice7/test/commits/5d0b92e26448a9e91db794bfed4b8c3556eabc4e)
|
|
|
|
* **Status**: failed :thumbs_down:
|
|
|
|
""".strip()
|
2016-12-31 18:06:29 +01:00
|
|
|
|
|
|
|
self.send_and_test_stream_message('build_002', expected_topic, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_solano_message_received(self) -> None:
|
2017-01-05 01:02:03 +01:00
|
|
|
"""
|
|
|
|
Build notifications are generated by Solano Labs after build completes.
|
|
|
|
"""
|
|
|
|
expected_topic = u'build update'
|
2019-04-18 23:25:03 +02:00
|
|
|
expected_message = """
|
|
|
|
Build update (see [build log](https://ci.solanolabs.com:443/reports/3317799)):
|
|
|
|
* **Author**: solano-ci[bot]@users.noreply.github.com
|
|
|
|
* **Commit**: [191d34f](github.com/anirudhjain75/scipy/commit/191d34f9da8ff7279b051cd68e44223253e18408)
|
|
|
|
* **Status**: running :arrows_counterclockwise:
|
|
|
|
""".strip()
|
2017-01-05 01:02:03 +01:00
|
|
|
|
|
|
|
self.send_and_test_stream_message('received', expected_topic, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_solano_test_message(self) -> None:
|
2017-04-11 08:58:23 +02:00
|
|
|
expected_topic = u'build update'
|
2019-04-18 23:25:03 +02:00
|
|
|
expected_message = "Solano webhook set up correctly."
|
2017-04-11 08:58:23 +02:00
|
|
|
|
|
|
|
self.send_and_test_stream_message('test', expected_topic, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2018-05-10 19:34:01 +02:00
|
|
|
def get_body(self, fixture_name: str) -> str:
|
2018-04-20 03:57:21 +02:00
|
|
|
return self.webhook_fixture_data(self.FIXTURE_DIR_NAME, fixture_name, file_type="json")
|