test_auth_backends: Add missing type annotations.

This commit is contained in:
Tim Abbott
2016-07-29 15:48:40 -07:00
parent 0689485666
commit cc11229377

View File

@@ -14,7 +14,7 @@ from zerver.lib.test_helpers import (
AuthedTestCase
)
from zerver.models import \
get_realm, get_user_profile_by_email, email_to_username
get_realm, get_user_profile_by_email, email_to_username, UserProfile
from zproject.backends import ZulipDummyBackend, EmailAuthBackend, \
GoogleMobileOauth2Backend, ZulipRemoteUserBackend, ZulipLDAPAuthBackend, \
@@ -159,6 +159,7 @@ class AuthBackendTest(TestCase):
email_to_username=email_to_username)
def test_github_backend(self):
# type: () -> None
email = 'hamlet@zulip.com'
good_kwargs = dict(response=dict(email=email), return_data=dict())
bad_kwargs = dict() # type: Dict[str, str]
@@ -168,6 +169,7 @@ class AuthBackendTest(TestCase):
class GitHubAuthBackendTest(AuthedTestCase):
def setUp(self):
# type: () -> None
self.email = 'hamlet@zulip.com'
self.name = 'Hamlet'
self.backend = GitHubAuthBackend()
@@ -176,7 +178,9 @@ class GitHubAuthBackendTest(AuthedTestCase):
self.user_profile.backend = self.backend
def test_github_backend_do_auth(self):
# type: () -> None
def do_auth(*args, **kwargs):
# type: (*Any, **Any) -> UserProfile
return self.user_profile
with mock.patch('zerver.views.login_or_register_remote_user') as result, \
@@ -226,7 +230,9 @@ class GitHubAuthBackendTest(AuthedTestCase):
self.backend.do_auth('fake-access-token', response=response)
def test_github_backend_inactive_user(self):
# type: () -> None
def do_auth_inactive(*args, **kwargs):
# type: (*Any, **Any) -> UserProfile
return_data = kwargs['return_data']
return_data['inactive_user'] = True
return self.user_profile
@@ -240,6 +246,7 @@ class GitHubAuthBackendTest(AuthedTestCase):
self.assertIs(user, None)
def test_github_backend_new_user(self):
# type: () -> None
rf = RequestFactory()
request = rf.get('/complete')
request.session = {}
@@ -247,6 +254,7 @@ class GitHubAuthBackendTest(AuthedTestCase):
self.backend.strategy.request = request
def do_auth(*args, **kwargs):
# type: (*Any, **Any) -> UserProfile
return_data = kwargs['return_data']
return_data['valid_attestation'] = True
return None