2016-11-10 19:30:09 +01:00
from zerver . lib . test_classes import WebhookTestCase
2016-09-20 22:51:11 +02:00
2020-01-14 22:06:24 +01:00
2016-09-20 22:51:11 +02:00
class CodeshipHookTests ( WebhookTestCase ) :
STREAM_NAME = ' codeship '
2020-04-09 21:51:58 +02:00
URL_TEMPLATE = " /api/v1/external/codeship?stream= {stream} &api_key= {api_key} "
TOPIC = " codeship/docs "
2016-09-20 22:51:11 +02:00
FIXTURE_DIR_NAME = ' codeship '
2017-11-04 07:47:46 +01:00
def test_codeship_build_in_testing_status_message ( self ) - > None :
2016-09-20 22:51:11 +02:00
"""
Tests if codeship testing status is mapped correctly
"""
2020-04-09 21:51:58 +02:00
expected_message = " [Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started. "
2018-11-09 21:23:38 +01:00
self . send_and_test_stream_message ( ' testing_build ' , self . TOPIC , expected_message )
2016-09-20 22:51:11 +02:00
2017-11-04 07:47:46 +01:00
def test_codeship_build_in_error_status_message ( self ) - > None :
2016-09-20 22:51:11 +02:00
"""
Tests if codeship error status is mapped correctly
"""
2020-04-09 21:51:58 +02:00
expected_message = " [Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed. "
2018-11-09 21:23:38 +01:00
self . send_and_test_stream_message ( ' error_build ' , self . TOPIC , expected_message )
2016-09-20 22:51:11 +02:00
2017-11-04 07:47:46 +01:00
def test_codeship_build_in_success_status_message ( self ) - > None :
2016-09-20 22:51:11 +02:00
"""
Tests if codeship success status is mapped correctly
"""
2020-04-09 21:51:58 +02:00
expected_message = " [Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded. "
2018-11-09 21:23:38 +01:00
self . send_and_test_stream_message ( ' success_build ' , self . TOPIC , expected_message )
2016-09-20 22:51:11 +02:00
2017-11-04 07:47:46 +01:00
def test_codeship_build_in_other_status_status_message ( self ) - > None :
2016-09-20 22:51:11 +02:00
"""
Tests if codeship other status is mapped correctly
"""
2020-04-09 21:51:58 +02:00
expected_message = " [Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status. "
2018-11-09 21:23:38 +01:00
self . send_and_test_stream_message ( ' other_status_build ' , self . TOPIC , expected_message )