mirror of https://github.com/zulip/zulip.git
mypy: Use Python 3 type syntax in zerver/lib/test_classes.py.
This commit is contained in:
parent
96fa399ce0
commit
21e629f351
|
@ -359,9 +359,8 @@ class ZulipTestCase(TestCase):
|
|||
)
|
||||
return [cast(Text, get_display_recipient(sub.recipient)) for sub in subs]
|
||||
|
||||
def send_personal_message(self, from_email, to_email, content="test content",
|
||||
sender_realm="zulip"):
|
||||
# type: (Text, Text, Text, Text) -> int
|
||||
def send_personal_message(self, from_email: Text, to_email: Text, content: Text="test content",
|
||||
sender_realm: Text="zulip") -> int:
|
||||
sender = get_user(from_email, get_realm(sender_realm))
|
||||
|
||||
recipient_list = [to_email]
|
||||
|
@ -372,9 +371,8 @@ class ZulipTestCase(TestCase):
|
|||
content
|
||||
)
|
||||
|
||||
def send_huddle_message(self, from_email, to_emails, content="test content",
|
||||
sender_realm="zulip"):
|
||||
# type: (Text, List[Text], Text, Text) -> int
|
||||
def send_huddle_message(self, from_email: Text, to_emails: List[Text], content: Text="test content",
|
||||
sender_realm: Text="zulip") -> int:
|
||||
sender = get_user(from_email, get_realm(sender_realm))
|
||||
|
||||
assert(len(to_emails) >= 2)
|
||||
|
@ -386,9 +384,8 @@ class ZulipTestCase(TestCase):
|
|||
content
|
||||
)
|
||||
|
||||
def send_stream_message(self, sender_email, stream_name, content="test content",
|
||||
topic_name="test", sender_realm="zulip"):
|
||||
# type: (Text, Text, Text, Text, Text) -> int
|
||||
def send_stream_message(self, sender_email: Text, stream_name: Text, content: Text="test content",
|
||||
topic_name: Text="test", sender_realm: Text="zulip") -> int:
|
||||
sender = get_user(sender_email, get_realm(sender_realm))
|
||||
|
||||
(sending_client, _) = Client.objects.get_or_create(name="test suite")
|
||||
|
@ -401,9 +398,8 @@ class ZulipTestCase(TestCase):
|
|||
body=content,
|
||||
)
|
||||
|
||||
def get_messages(self, anchor=1, num_before=100, num_after=100,
|
||||
use_first_unread_anchor=False):
|
||||
# type: (int, int, int, bool) -> List[Dict[str, Any]]
|
||||
def get_messages(self, anchor: int=1, num_before: int=100, num_after: int=100,
|
||||
use_first_unread_anchor: bool=False) -> List[Dict[str, Any]]:
|
||||
post_params = {"anchor": anchor, "num_before": num_before,
|
||||
"num_after": num_after,
|
||||
"use_first_unread_anchor": ujson.dumps(use_first_unread_anchor)}
|
||||
|
@ -529,9 +525,9 @@ class ZulipTestCase(TestCase):
|
|||
bulk_remove_subscriptions([user_profile], [stream])
|
||||
|
||||
# Subscribe to a stream by making an API request
|
||||
def common_subscribe_to_streams(self, email, streams, extra_post_data={}, invite_only=False,
|
||||
**kwargs):
|
||||
# type: (Text, Iterable[Text], Dict[str, Any], bool, **Any) -> HttpResponse
|
||||
def common_subscribe_to_streams(self, email: Text, streams: Iterable[Text],
|
||||
extra_post_data: Dict[str, Any]={}, invite_only: bool=False,
|
||||
**kwargs: Any) -> HttpResponse:
|
||||
post_data = {'subscriptions': ujson.dumps([{"name": stream} for stream in streams]),
|
||||
'invite_only': ujson.dumps(invite_only)}
|
||||
post_data.update(extra_post_data)
|
||||
|
@ -607,9 +603,9 @@ class WebhookTestCase(ZulipTestCase):
|
|||
def setUp(self) -> None:
|
||||
self.url = self.build_webhook_url()
|
||||
|
||||
def send_and_test_stream_message(self, fixture_name, expected_subject=None,
|
||||
expected_message=None, content_type="application/json", **kwargs):
|
||||
# type: (Text, Optional[Text], Optional[Text], Optional[Text], **Any) -> Message
|
||||
def send_and_test_stream_message(self, fixture_name: Text, expected_subject: Optional[Text]=None,
|
||||
expected_message: Optional[Text]=None,
|
||||
content_type: Optional[Text]="application/json", **kwargs: Any) -> Message:
|
||||
payload = self.get_body(fixture_name)
|
||||
if content_type is not None:
|
||||
kwargs['content_type'] = content_type
|
||||
|
@ -620,9 +616,9 @@ class WebhookTestCase(ZulipTestCase):
|
|||
|
||||
return msg
|
||||
|
||||
def send_and_test_private_message(self, fixture_name, expected_subject=None,
|
||||
expected_message=None, content_type="application/json", **kwargs):
|
||||
# type: (Text, Text, Text, str, **Any) -> Message
|
||||
def send_and_test_private_message(self, fixture_name: Text, expected_subject: Text=None,
|
||||
expected_message: Text=None, content_type: str="application/json",
|
||||
**kwargs: Any)-> Message:
|
||||
payload = self.get_body(fixture_name)
|
||||
if content_type is not None:
|
||||
kwargs['content_type'] = content_type
|
||||
|
|
Loading…
Reference in New Issue