2016-09-20 22:51:11 +02:00
# -*- coding: utf-8 -*-
2017-11-16 00:43:10 +01:00
2016-11-10 19:30:09 +01:00
from zerver . lib . test_classes import WebhookTestCase
2016-09-20 22:51:11 +02:00
class SemaphoreHookTests ( WebhookTestCase ) :
STREAM_NAME = ' semaphore '
URL_TEMPLATE = " /api/v1/external/semaphore?stream= {stream} &api_key= {api_key} "
# Messages are generated by Semaphore on git push. The subject lines below
# contain information on the repo and branch, and the message has links and
# details about the build, deploy, server, author, and commit
2017-11-04 07:47:46 +01:00
def test_semaphore_build ( self ) - > None :
2018-11-09 20:33:58 +01:00
expected_topic = u " knighthood/master " # repo/branch
2016-09-20 22:51:11 +02:00
expected_message = u """ [build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314): passed
! avatar ( don @lamancha.com ) [ ` a490b8d ` ] ( https : / / github . com / donquixote / knighthood / commit / a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf ) : Create user account for Rocinante : horse : . """
2018-11-09 20:33:58 +01:00
self . send_and_test_stream_message ( ' build ' , expected_topic , expected_message ,
2016-09-20 22:51:11 +02:00
content_type = " application/x-www-form-urlencoded " )
2017-11-04 07:47:46 +01:00
def test_semaphore_deploy ( self ) - > None :
2018-11-09 20:33:58 +01:00
expected_topic = u " knighthood/master "
2016-09-20 22:51:11 +02:00
expected_message = u """ [deploy 17](https://semaphoreci.com/donquixote/knighthood/servers/lamancha-271/deploys/17) of [build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314) on server lamancha-271: passed
! avatar ( don @lamancha.com ) [ ` a490b8d ` ] ( https : / / github . com / donquixote / knighthood / commit / a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf ) : Create user account for Rocinante : horse : . """
2018-11-09 20:33:58 +01:00
self . send_and_test_stream_message ( ' deploy ' , expected_topic , expected_message ,
2016-09-20 22:51:11 +02:00
content_type = " application/x-www-form-urlencoded " )
2018-05-10 19:34:01 +02:00
def get_body ( self , fixture_name : str ) - > str :
2018-04-20 03:57:21 +02:00
return self . webhook_fixture_data ( " semaphore " , fixture_name , file_type = " json " )