2016-09-20 22:51:11 +02:00
# -*- coding: utf-8 -*-
2016-12-04 18:38:56 +01:00
from typing import Text
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 HelloWorldHookTests ( WebhookTestCase ) :
STREAM_NAME = ' test '
URL_TEMPLATE = " /api/v1/external/helloworld?&api_key= {api_key} "
FIXTURE_DIR_NAME = ' hello '
# Note: Include a test function per each distinct message condition your integration supports
2017-11-04 07:47:46 +01:00
def test_hello_message ( self ) - > None :
2016-11-09 13:44:29 +01:00
expected_subject = u " Hello World "
expected_message = u " Hello! I am happy to be here! :smile: \n The Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)** "
2016-09-20 22:51:11 +02:00
# use fixture named helloworld_hello
self . send_and_test_stream_message ( ' hello ' , expected_subject , expected_message ,
content_type = " application/x-www-form-urlencoded " )
2017-11-04 07:47:46 +01:00
def test_goodbye_message ( self ) - > None :
2016-11-09 13:44:29 +01:00
expected_subject = u " Hello World "
expected_message = u " Hello! I am happy to be here! :smile: \n The Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)** "
2016-09-20 22:51:11 +02:00
# use fixture named helloworld_goodbye
self . send_and_test_stream_message ( ' goodbye ' , expected_subject , expected_message ,
content_type = " application/x-www-form-urlencoded " )
2017-11-04 07:47:46 +01:00
def get_body ( self , fixture_name : Text ) - > Text :
2016-09-20 22:51:11 +02:00
return self . fixture_data ( " helloworld " , fixture_name , file_type = " json " )