2016-12-02 12:06:20 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-11-16 00:43:10 +01:00
|
|
|
|
2016-12-02 12:06:20 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
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"
|
2016-12-02 12:06:20 +01:00
|
|
|
expected_message = u"""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
|
|
|
|
```"""
|
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
|
|
|
|
```"""
|
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")
|