test_auth_backends: Fix strict_optional_errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-04 16:28:06 -07:00 committed by Tim Abbott
parent d690cc32e1
commit 3a7a828139
2 changed files with 3 additions and 5 deletions

View File

@ -40,8 +40,6 @@ strict_optional = True
# Tests (may be many issues in file; comment is just one error noted)
[mypy-zerver/tests/test_auth_backends] #2079: error: Incompatible types in assignment (expression has type "Optional[UserProfile]", variable has type "UserProfile")
strict_optional = False
[mypy-zerver/tests/test_signup] #1954: error: Item "None" of "Optional[Match[Any]]" has no attribute "groups"
strict_optional = False
[mypy-zerver/tests/test_realm] #191: error: Item "None" of "Optional[Stream]" has no attribute "id"

View File

@ -319,6 +319,7 @@ class AuthBackendTest(ZulipTestCase):
result = self.client_get('/login/?preview=true')
self.assertEqual(result.status_code, 200)
self.assert_in_response(realm.description, result)
assert realm.name is not None
self.assert_in_response(realm.name, result)
self.assert_in_response("Log in to Zulip", result)
@ -1501,6 +1502,7 @@ class SAMLAuthBackendTest(SocialAuthBase):
relay_state = urllib.parse.parse_qs(parsed_url.query)['RelayState'][0]
# Make sure params are getting encoded into RelayState:
data = SAMLAuthBackend.get_data_from_redis(ujson.loads(relay_state)['state_token'])
assert data is not None
if next:
self.assertEqual(data['next'], next)
if is_signup:
@ -2220,7 +2222,7 @@ class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase):
"""
if not skip_id_token:
id_token = self.generate_id_token(account_data_dict, settings.SOCIAL_AUTH_APPLE_BUNDLE_ID)
id_token: Optional[str] = self.generate_id_token(account_data_dict, settings.SOCIAL_AUTH_APPLE_BUNDLE_ID)
else:
id_token = None
@ -3061,8 +3063,6 @@ class GoogleAuthBackendTest(SocialAuthBase):
def test_log_into_subdomain_when_email_is_none(self) -> None:
data: ExternalAuthDataDict = {
'full_name': None,
'email': None,
'subdomain': 'zulip',
'is_signup': False,
'redirect_to': '',