mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
tests: Fix str/Text mypy issues in various tests.
This commit is contained in:
@@ -210,32 +210,32 @@ class ZulipTestCase(TestCase):
|
||||
return django_client.get(url, info, **kwargs)
|
||||
|
||||
example_user_map = dict(
|
||||
hamlet='hamlet@zulip.com',
|
||||
cordelia='cordelia@zulip.com',
|
||||
iago='iago@zulip.com',
|
||||
prospero='prospero@zulip.com',
|
||||
othello='othello@zulip.com',
|
||||
AARON='AARON@zulip.com',
|
||||
aaron='aaron@zulip.com',
|
||||
ZOE='ZOE@zulip.com',
|
||||
hamlet=u'hamlet@zulip.com',
|
||||
cordelia=u'cordelia@zulip.com',
|
||||
iago=u'iago@zulip.com',
|
||||
prospero=u'prospero@zulip.com',
|
||||
othello=u'othello@zulip.com',
|
||||
AARON=u'AARON@zulip.com',
|
||||
aaron=u'aaron@zulip.com',
|
||||
ZOE=u'ZOE@zulip.com',
|
||||
)
|
||||
|
||||
mit_user_map = dict(
|
||||
sipbtest="sipbtest@mit.edu",
|
||||
starnine="starnine@mit.edu",
|
||||
espuser="espuser@mit.edu",
|
||||
sipbtest=u"sipbtest@mit.edu",
|
||||
starnine=u"starnine@mit.edu",
|
||||
espuser=u"espuser@mit.edu",
|
||||
)
|
||||
|
||||
# Non-registered test users
|
||||
nonreg_user_map = dict(
|
||||
test='test@zulip.com',
|
||||
test1='test1@zulip.com',
|
||||
alice='alice@zulip.com',
|
||||
newuser='newuser@zulip.com',
|
||||
bob='bob@zulip.com',
|
||||
cordelia='cordelia@zulip.com',
|
||||
newguy='newguy@zulip.com',
|
||||
me='me@zulip.com',
|
||||
test=u'test@zulip.com',
|
||||
test1=u'test1@zulip.com',
|
||||
alice=u'alice@zulip.com',
|
||||
newuser=u'newuser@zulip.com',
|
||||
bob=u'bob@zulip.com',
|
||||
cordelia=u'cordelia@zulip.com',
|
||||
newguy=u'newguy@zulip.com',
|
||||
me=u'me@zulip.com',
|
||||
)
|
||||
|
||||
def nonreg_user(self, name):
|
||||
@@ -254,15 +254,15 @@ class ZulipTestCase(TestCase):
|
||||
return get_user_profile_by_email(email)
|
||||
|
||||
def nonreg_email(self, name):
|
||||
# type: (str) -> str
|
||||
# type: (str) -> Text
|
||||
return self.nonreg_user_map[name]
|
||||
|
||||
def example_email(self, name):
|
||||
# type: (str) -> str
|
||||
# type: (str) -> Text
|
||||
return self.example_user_map[name]
|
||||
|
||||
def mit_email(self, name):
|
||||
# type: (str) -> str
|
||||
# type: (str) -> Text
|
||||
return self.mit_user_map[name]
|
||||
|
||||
def notification_bot(self):
|
||||
|
||||
@@ -499,8 +499,8 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||
# type: () -> None
|
||||
self.login(self.example_email('hamlet'))
|
||||
bot_info = {
|
||||
'full_name': 'The Bot of Hamlet',
|
||||
'short_name': 'hambot',
|
||||
'full_name': u'The Bot of Hamlet',
|
||||
'short_name': u'hambot',
|
||||
}
|
||||
result = self.client_post("/json/bots", bot_info)
|
||||
self.assert_json_success(result)
|
||||
|
||||
@@ -34,7 +34,7 @@ from zerver.lib.validator import (
|
||||
check_variable_type, equals, check_none_or,
|
||||
)
|
||||
from zerver.models import \
|
||||
get_realm, get_user, UserProfile, Client
|
||||
get_realm, get_user, UserProfile, Client, Realm
|
||||
|
||||
import ujson
|
||||
|
||||
@@ -986,12 +986,12 @@ class TestAuthenticatedJsonPostViewDecorator(ZulipTestCase):
|
||||
do_reactivate_realm(user_profile.realm)
|
||||
|
||||
def _do_test(self, user_email):
|
||||
# type: (str) -> HttpResponse
|
||||
# type: (Text) -> HttpResponse
|
||||
data = {"status": '"started"'}
|
||||
return self.client_post(r'/json/tutorial_status', data)
|
||||
|
||||
def _login(self, user_email, user_realm, password=None):
|
||||
# type: (str, str) -> None
|
||||
# type: (Text, Realm, str) -> None
|
||||
if password:
|
||||
user_profile = get_user(user_email, user_realm)
|
||||
user_profile.set_password(password)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, Text
|
||||
|
||||
from zerver.lib.sessions import (
|
||||
user_sessions,
|
||||
@@ -20,7 +20,7 @@ from zerver.lib.test_classes import ZulipTestCase
|
||||
class TestSessions(ZulipTestCase):
|
||||
|
||||
def do_test_session(self, user, action, expected_result):
|
||||
# type: (str, Callable[[], Any], bool) -> None
|
||||
# type: (Text, Callable[[], Any], bool) -> None
|
||||
self.login(user)
|
||||
self.assertIn('_auth_user_id', self.client.session)
|
||||
action()
|
||||
|
||||
@@ -340,7 +340,7 @@ class LoginTest(ZulipTestCase):
|
||||
class InviteUserTest(ZulipTestCase):
|
||||
|
||||
def invite(self, users, streams, body=''):
|
||||
# type: (str, List[Text], str) -> HttpResponse
|
||||
# type: (Text, List[Text], str) -> HttpResponse
|
||||
"""
|
||||
Invites the specified users to Zulip with the specified streams.
|
||||
|
||||
@@ -356,7 +356,7 @@ class InviteUserTest(ZulipTestCase):
|
||||
"custom_body": body})
|
||||
|
||||
def check_sent_emails(self, correct_recipients, custom_body=None):
|
||||
# type: (List[str], Optional[str]) -> None
|
||||
# type: (List[Text], Optional[str]) -> None
|
||||
from django.core.mail import outbox
|
||||
self.assertEqual(len(outbox), len(correct_recipients))
|
||||
email_recipients = [email.recipients()[0] for email in outbox]
|
||||
@@ -545,8 +545,8 @@ earl-test@zulip.com""", ["Denmark"]))
|
||||
only sent to the new users.
|
||||
"""
|
||||
self.login("hamlet@zulip.com")
|
||||
existing = ["hamlet@zulip.com", "othello@zulip.com"]
|
||||
new = ["foo-test@zulip.com", "bar-test@zulip.com"]
|
||||
existing = [u"hamlet@zulip.com", u"othello@zulip.com"]
|
||||
new = [u"foo-test@zulip.com", u"bar-test@zulip.com"]
|
||||
|
||||
result = self.client_post("/json/invite_users",
|
||||
{"invitee_emails": "\n".join(existing + new),
|
||||
|
||||
@@ -1543,7 +1543,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
"Invalid stream name '%s'" % (invalid_stream_name,))
|
||||
|
||||
def assert_adding_subscriptions_for_principal(self, invitee_email, invitee_realm, streams, invite_only=False):
|
||||
# type: (Text, List[Text], bool) -> None
|
||||
# type: (Text, Realm, List[Text], bool) -> None
|
||||
"""
|
||||
Calling POST /json/users/me/subscriptions on behalf of another principal (for
|
||||
whom you have permission to add subscriptions) should successfully add
|
||||
|
||||
Reference in New Issue
Block a user