Files
zulip/zerver/webhooks/yo/tests.py
Steve Howell 7fbe08f515 webhook tests: Introduce get_payload.
We introduce get_payload for the relatively
exceptional cases where webhooks return payloads
as dicts.

Having a simple "str" type for get_body will
allow us to extract test helpers that use
payloads from get_body() without the ugly
`Union[str, Dict[str, str]]` annotations.

I also tightened up annotations in a few places
where we now call get_payload (using Dict[str, str]
instead of Dict[str, Any]).

In the zendesk test I explicitly stringify
one of the parameters to satisfy mypy.
2020-08-24 12:34:46 -07:00

27 lines
872 B
Python

from typing import Dict
from zerver.lib.test_classes import WebhookTestCase
class YoHookTests(WebhookTestCase):
STREAM_NAME = 'yo'
URL_TEMPLATE = "/api/v1/external/yo?api_key={api_key}"
FIXTURE_DIR_NAME = 'yo'
def test_yo_message(self) -> None:
"""
Yo App sends notification whenever user receives a new Yo from another user.
"""
cordelia = self.example_user('cordelia')
self.url = self.build_webhook_url(
email=cordelia.email,
username="IAGO",
user_ip="127.0.0.1",
)
expected_message = "Yo from IAGO"
self.send_and_test_private_message('', expected_message=expected_message,
content_type="application/x-www-form-urlencoded")
def get_payload(self, fixture_name: str) -> Dict[str, str]:
return {}