mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
Almost all webhook tests use this helper, except a few webhooks that write to private streams. Being concise is important here, and the name `self.send_and_test_stream_message` always confused me, since it sounds you're sending a stream message, and it leaves out the webhook piece. We should consider renaming `send_and_test_private_message` to something like `check_webhook_private`, but I couldn't decide on a great name, and it's very rarely used. So for now I just made sure the docstrings of the two sibling functions reference each other.
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
class HerokuHookTests(WebhookTestCase):
|
|
STREAM_NAME = 'heroku'
|
|
URL_TEMPLATE = "/api/v1/external/heroku?stream={stream}&api_key={api_key}"
|
|
|
|
def test_deployment(self) -> None:
|
|
expected_topic = "sample-project"
|
|
expected_message = """
|
|
user@example.com deployed version 3eb5f44 of [sample-project](http://sample-project.herokuapp.com):
|
|
|
|
``` quote
|
|
* Example User: Test commit for Deploy Hook 2
|
|
```
|
|
""".strip()
|
|
self.check_webhook(
|
|
"deploy",
|
|
expected_topic,
|
|
expected_message,
|
|
content_type="application/x-www-form-urlencoded",
|
|
)
|
|
|
|
def test_deployment_multiple_commits(self) -> None:
|
|
expected_topic = "sample-project"
|
|
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
|
|
```"""
|
|
|
|
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()
|
|
self.check_webhook(
|
|
"deploy_multiple_commits",
|
|
expected_topic,
|
|
expected_message,
|
|
content_type="application/x-www-form-urlencoded",
|
|
)
|
|
|
|
def get_body(self, fixture_name: str) -> str:
|
|
return self.webhook_fixture_data("heroku", fixture_name, file_type="txt")
|