mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
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.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict
|
||||
from typing import Dict
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
@@ -7,10 +7,10 @@ class ZenDeskHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'zendesk'
|
||||
URL_TEMPLATE = "/api/v1/external/zendesk?stream={stream}"
|
||||
|
||||
def get_body(self, fixture_name: str) -> Dict[str, Any]:
|
||||
def get_payload(self, fixture_name: str) -> Dict[str, str]:
|
||||
return {
|
||||
'ticket_title': self.TICKET_TITLE,
|
||||
'ticket_id': self.TICKET_ID,
|
||||
'ticket_id': str(self.TICKET_ID),
|
||||
'message': self.MESSAGE,
|
||||
'stream': self.STREAM_NAME,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user