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 ) :
2021-02-12 08:20:45 +01:00
STREAM_NAME = " codeship "
2020-04-09 21:51:58 +02:00
URL_TEMPLATE = " /api/v1/external/codeship?stream= {stream} &api_key= {api_key} "
2024-01-17 15:53:30 +01:00
TOPIC_NAME = " codeship/docs "
2021-06-26 09:18:33 +02:00
WEBHOOK_DIR_NAME = " codeship "
2016-09-20 22:51:11 +02:00
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. "
2024-01-17 15:53:30 +01:00
self . check_webhook ( " testing_build " , self . TOPIC_NAME , 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. "
2024-01-17 15:53:30 +01:00
self . check_webhook ( " error_build " , self . TOPIC_NAME , 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. "
2024-01-17 15:53:30 +01:00
self . check_webhook ( " success_build " , self . TOPIC_NAME , 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. "
2024-01-17 15:53:30 +01:00
self . check_webhook ( " other_status_build " , self . TOPIC_NAME , expected_message )