Files
zulip/zerver/webhooks/delighted/tests.py
PIG208 5ecbfecd77 webhook: Rename FIXTURE_DIR_NAME to WEBHOOK_DIR_NAME.
Since FIXTURE_DIR_NAME is the name of the folder that contains the view
and tests modules of the webhook and another folder called "fixtures" that
store the fixtures, it is more appropriate to call it WEBHOOK_DIR_NAME,
especially when we want to refer to the view module using this variable.
2021-06-29 17:01:54 -07:00

48 lines
1.4 KiB
Python

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}"
WEBHOOK_DIR_NAME = "delighted"
def test_feedback_message_promoter(self) -> None:
expected_topic = "Survey response"
expected_message = """
Kudos! You have a new promoter. Score of 9/10 from charlie_gravis@example.com:
``` quote
Your service is fast and flawless!
```
""".strip()
self.check_webhook(
"survey_response_updated_promoter",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_feedback_message_non_promoter(self) -> None:
expected_topic = "Survey response"
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!"
)
expected_message = """
Great! You have new feedback. Score of 5/10 from paul_gravis@example.com:
``` quote
Your service is slow, but nearly flawless! Keep up the good work!
```
""".strip()
self.check_webhook(
"survey_response_updated_non_promoter",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)