2016-12-24 15:50:28 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-11-16 00:43:10 +01:00
|
|
|
|
2016-12-24 15:50:28 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
class DelightedHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'delighted'
|
|
|
|
URL_TEMPLATE = "/api/v1/external/delighted?stream={stream}&api_key={api_key}"
|
|
|
|
FIXTURE_DIR_NAME = 'delighted'
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_feedback_message_promoter(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "Survey Response"
|
2016-12-24 15:50:28 +01:00
|
|
|
expected_message = ("Kudos! You have a new promoter.\n"
|
|
|
|
">Score of 9/10 from charlie_gravis@example.com"
|
|
|
|
"\n>Your service is fast and flawless!")
|
|
|
|
|
|
|
|
self.send_and_test_stream_message('survey_response_updated_promoter',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2016-12-24 15:50:28 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_feedback_message_non_promoter(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "Survey Response"
|
2016-12-24 15:50:28 +01:00
|
|
|
expected_message = ("Great! You have new feedback.\n"
|
|
|
|
">Score of 5/10 from paul_gravis@example.com"
|
|
|
|
"\n>Your service is slow, but nearly flawless! "
|
|
|
|
"Keep up the good work!")
|
|
|
|
|
|
|
|
self.send_and_test_stream_message('survey_response_updated_non_promoter',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2016-12-24 15:50:28 +01:00
|
|
|
expected_message,
|
|
|
|
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("delighted", fixture_name, file_type="json")
|