Files
zulip/zerver/webhooks/appveyor/tests.py
Steve Howell 388053db6b webhook tests: Rename main helper to check_webhook.
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.
2020-08-24 12:34:46 -07:00

39 lines
1.6 KiB
Python

from zerver.lib.test_classes import WebhookTestCase
class AppveyorHookTests(WebhookTestCase):
STREAM_NAME = 'appveyor'
URL_TEMPLATE = "/api/v1/external/appveyor?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = 'appveyor'
def test_appveyor_build_success_message(self) -> None:
"""
Tests if appveyor build success notification is handled correctly
"""
expected_topic = "Hubot-DSC-Resource"
expected_message = """
[Build Hubot-DSC-Resource 2.0.59 completed](https://ci.appveyor.com/project/joebloggs/hubot-dsc-resource/build/2.0.59):
* **Commit**: [c06e208b47: Increment version number.](https://github.com/joebloggs/Hubot-DSC-Resource/commit/c06e208b47) by Joe Bloggs
* **Started**: 9/9/2018 7:04 PM
* **Finished**: 9/9/2018 7:06 PM
""".strip()
self.check_webhook("appveyor_build_success", expected_topic, expected_message)
def test_appveyor_build_failure_message(self) -> None:
"""
Tests if appveyor build failure notification is handled correctly
"""
expected_topic = "Hubot-DSC-Resource"
expected_message = """
[Build Hubot-DSC-Resource 2.0.59 failed](https://ci.appveyor.com/project/joebloggs/hubot-dsc-resource/build/2.0.59):
* **Commit**: [c06e208b47: Increment version number.](https://github.com/joebloggs/Hubot-DSC-Resource/commit/c06e208b47) by Joe Bloggs
* **Started**: 9/9/2018 7:04 PM
* **Finished**: 9/9/2018 7:06 PM
""".strip()
self.check_webhook("appveyor_build_failure", expected_topic, expected_message)
def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("appveyor", fixture_name, file_type="json")