Files
zulip/zerver/webhooks/codeship/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

37 lines
1.7 KiB
Python

from zerver.lib.test_classes import WebhookTestCase
class CodeshipHookTests(WebhookTestCase):
STREAM_NAME = 'codeship'
URL_TEMPLATE = "/api/v1/external/codeship?stream={stream}&api_key={api_key}"
TOPIC = "codeship/docs"
FIXTURE_DIR_NAME = 'codeship'
def test_codeship_build_in_testing_status_message(self) -> None:
"""
Tests if codeship testing status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started."
self.check_webhook("testing_build", self.TOPIC, expected_message)
def test_codeship_build_in_error_status_message(self) -> None:
"""
Tests if codeship error status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed."
self.check_webhook("error_build", self.TOPIC, expected_message)
def test_codeship_build_in_success_status_message(self) -> None:
"""
Tests if codeship success status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded."
self.check_webhook("success_build", self.TOPIC, expected_message)
def test_codeship_build_in_other_status_status_message(self) -> None:
"""
Tests if codeship other status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status."
self.check_webhook("other_status_build", self.TOPIC, expected_message)