mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
zerver/webhooks: Change use of typing.Text to str.
This commit is contained in:
committed by
Tim Abbott
parent
e8506b5020
commit
64ddfc6ac0
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class StatuspageHookTests(WebhookTestCase):
|
||||
@@ -34,5 +33,5 @@ from **operational** to **under_maintenance**"
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
||||
def get_body(self, fixture_name: Text) -> Text:
|
||||
def get_body(self, fixture_name: str) -> str:
|
||||
return self.webhook_fixture_data("statuspage", fixture_name, file_type="json")
|
||||
|
||||
@@ -5,33 +5,33 @@ from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
|
||||
from zerver.models import get_client, UserProfile
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Text
|
||||
from typing import Dict, Any
|
||||
|
||||
INCIDENT_TEMPLATE = u'**{name}** \n * State: **{state}** \n * Description: {content}'
|
||||
COMPONENT_TEMPLATE = u'**{name}** has changed status from **{old_status}** to **{new_status}**'
|
||||
TOPIC_TEMPLATE = u'{name}: {description}'
|
||||
|
||||
def get_incident_events_body(payload: Dict[Text, Any]) -> Text:
|
||||
def get_incident_events_body(payload: Dict[str, Any]) -> str:
|
||||
return INCIDENT_TEMPLATE.format(
|
||||
name = payload["incident"]["name"],
|
||||
state = payload["incident"]["status"],
|
||||
content = payload["incident"]["incident_updates"][0]["body"],
|
||||
)
|
||||
|
||||
def get_components_update_body(payload: Dict[Text, Any]) -> Text:
|
||||
def get_components_update_body(payload: Dict[str, Any]) -> str:
|
||||
return COMPONENT_TEMPLATE.format(
|
||||
name = payload["component"]["name"],
|
||||
old_status = payload["component_update"]["old_status"],
|
||||
new_status = payload["component_update"]["new_status"],
|
||||
)
|
||||
|
||||
def get_incident_topic(payload: Dict[Text, Any]) -> Text:
|
||||
def get_incident_topic(payload: Dict[str, Any]) -> str:
|
||||
return TOPIC_TEMPLATE.format(
|
||||
name = payload["incident"]["name"],
|
||||
description = payload["page"]["status_description"],
|
||||
)
|
||||
|
||||
def get_component_topic(payload: Dict[Text, Any]) -> Text:
|
||||
def get_component_topic(payload: Dict[str, Any]) -> str:
|
||||
return TOPIC_TEMPLATE.format(
|
||||
name = payload["component"]["name"],
|
||||
description = payload["page"]["status_description"],
|
||||
|
||||
Reference in New Issue
Block a user