From 6aaca44e1739cd32a05af93d0fd50e9ecaa86cbb Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 24 May 2017 15:17:02 -0700 Subject: [PATCH] tests: Fix str/Text mypy issues in various tests. --- zerver/lib/test_classes.py | 44 ++++++++++++++++----------------- zerver/tests/test_bots.py | 4 +-- zerver/tests/test_decorators.py | 6 ++--- zerver/tests/test_sessions.py | 4 +-- zerver/tests/test_signup.py | 8 +++--- zerver/tests/test_subs.py | 2 +- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 1f7d0646a1..4ded2b1c72 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -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): diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py index 4251263eda..ebddb91ff2 100644 --- a/zerver/tests/test_bots.py +++ b/zerver/tests/test_bots.py @@ -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) diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 5056d8c501..8c0c61de38 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -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) diff --git a/zerver/tests/test_sessions.py b/zerver/tests/test_sessions.py index 4fe5566595..8d511f7f91 100644 --- a/zerver/tests/test_sessions.py +++ b/zerver/tests/test_sessions.py @@ -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() diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index cc4a1957e5..621fdf1bc0 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -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), diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 3e5d6370ab..db101c0946 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -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