2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
|
|
|
|
2016-12-02 12:06:20 +01:00
|
|
|
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):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "heroku"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/heroku?stream={stream}&api_key={api_key}"
|
2016-12-02 12:06:20 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_deployment(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "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()
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"deploy",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|
2016-12-02 12:06:20 +01:00
|
|
|
|
2018-06-29 18:00:44 +02:00
|
|
|
def test_deployment_multiple_commits(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "sample-project"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = """user@example.com deployed version 3eb5f44 of \
|
2018-06-29 18:00:44 +02:00
|
|
|
[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()
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"deploy_multiple_commits",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|
2018-06-29 18:00:44 +02:00
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
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")
|