2016-12-02 12:06:20 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2016-12-02 12:06:20 +01:00
|
|
|
class HerokuHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'heroku'
|
|
|
|
URL_TEMPLATE = u"/api/v1/external/heroku?stream={stream}&api_key={api_key}"
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_deployment(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "sample-project"
|
2019-04-12 05:36:17 +02:00
|
|
|
expected_message = """
|
|
|
|
user@example.com deployed version 3eb5f44 of [sample-project](http://sample-project.herokuapp.com):
|
|
|
|
|
2018-06-29 18:00:44 +02:00
|
|
|
``` quote
|
|
|
|
* Example User: Test commit for Deploy Hook 2
|
2019-04-12 05:36:17 +02:00
|
|
|
```
|
|
|
|
""".strip()
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('deploy', expected_topic, expected_message,
|
2016-12-02 12:06:20 +01:00
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2018-06-29 18:00:44 +02:00
|
|
|
def test_deployment_multiple_commits(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "sample-project"
|
2018-06-29 18:00:44 +02:00
|
|
|
expected_message = u"""user@example.com deployed version 3eb5f44 of \
|
|
|
|
[sample-project](http://sample-project.herokuapp.com)
|
|
|
|
``` quote
|
|
|
|
* Example User: Test commit for Deploy Hook
|
|
|
|
* Example User: Second test commit for Deploy Hook 2
|
|
|
|
```"""
|
2019-04-12 05:36:17 +02:00
|
|
|
|
|
|
|
expected_message = """
|
|
|
|
user@example.com deployed version 3eb5f44 of [sample-project](http://sample-project.herokuapp.com):
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
* Example User: Test commit for Deploy Hook
|
|
|
|
* Example User: Second test commit for Deploy Hook 2
|
|
|
|
```
|
|
|
|
""".strip()
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('deploy_multiple_commits', expected_topic, expected_message,
|
2018-06-29 18:00:44 +02:00
|
|
|
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("heroku", fixture_name, file_type="txt")
|