mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 00:23:49 +00:00
test_signup: Fix strict_optional errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
3a7a828139
commit
e2965dcb52
2
mypy.ini
2
mypy.ini
@@ -40,8 +40,6 @@ strict_optional = True
|
|||||||
|
|
||||||
# Tests (may be many issues in file; comment is just one error noted)
|
# Tests (may be many issues in file; comment is just one error noted)
|
||||||
|
|
||||||
[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"
|
[mypy-zerver/tests/test_realm] #191: error: Item "None" of "Optional[Stream]" has no attribute "id"
|
||||||
strict_optional = False
|
strict_optional = False
|
||||||
[mypy-zerver/tests/test_messages] #3070: error: Incompatible types in assignment (expression has type "None", variable has type "int")
|
[mypy-zerver/tests/test_messages] #3070: error: Incompatible types in assignment (expression has type "None", variable has type "int")
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ class PasswordResetTest(ZulipTestCase):
|
|||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
email = user.delivery_email
|
email = user.delivery_email
|
||||||
old_password = initial_password(email)
|
old_password = initial_password(email)
|
||||||
|
assert old_password is not None
|
||||||
|
|
||||||
self.login_user(user)
|
self.login_user(user)
|
||||||
|
|
||||||
@@ -535,7 +536,7 @@ class LoginTest(ZulipTestCase):
|
|||||||
|
|
||||||
def test_login_bad_password(self) -> None:
|
def test_login_bad_password(self) -> None:
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
password = "wrongpassword"
|
password: Optional[str] = "wrongpassword"
|
||||||
result = self.login_with_return(user.delivery_email, password=password)
|
result = self.login_with_return(user.delivery_email, password=password)
|
||||||
self.assert_in_success_response([user.delivery_email], result)
|
self.assert_in_success_response([user.delivery_email], result)
|
||||||
self.assert_logged_in_user_id(None)
|
self.assert_logged_in_user_id(None)
|
||||||
@@ -1989,7 +1990,7 @@ class MultiuseInviteTest(ZulipTestCase):
|
|||||||
self.realm.invite_required = True
|
self.realm.invite_required = True
|
||||||
self.realm.save()
|
self.realm.save()
|
||||||
|
|
||||||
def generate_multiuse_invite_link(self, streams: List[Stream]=None,
|
def generate_multiuse_invite_link(self, streams: Optional[List[Stream]]=None,
|
||||||
date_sent: Optional[datetime.datetime]=None) -> str:
|
date_sent: Optional[datetime.datetime]=None) -> str:
|
||||||
invite = MultiuseInvite(realm=self.realm, referred_by=self.example_user("iago"))
|
invite = MultiuseInvite(realm=self.realm, referred_by=self.example_user("iago"))
|
||||||
invite.save()
|
invite.save()
|
||||||
@@ -3190,9 +3191,9 @@ class UserSignUpTest(InviteUserBase):
|
|||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
for message in reversed(outbox):
|
for message in reversed(outbox):
|
||||||
if email in message.to:
|
if email in message.to:
|
||||||
confirmation_link_pattern = re.compile(settings.EXTERNAL_HOST + r"(\S+)>")
|
match = re.search(settings.EXTERNAL_HOST + r"(\S+)>", message.body)
|
||||||
confirmation_url = confirmation_link_pattern.search(
|
assert match is not None
|
||||||
message.body).groups()[0]
|
[confirmation_url] = match.groups()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Couldn't find a confirmation email.")
|
raise AssertionError("Couldn't find a confirmation email.")
|
||||||
@@ -3258,9 +3259,9 @@ class UserSignUpTest(InviteUserBase):
|
|||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
for message in reversed(outbox):
|
for message in reversed(outbox):
|
||||||
if email in message.to:
|
if email in message.to:
|
||||||
confirmation_link_pattern = re.compile(settings.EXTERNAL_HOST + r"(\S+)>")
|
match = re.search(settings.EXTERNAL_HOST + r"(\S+)>", message.body)
|
||||||
confirmation_url = confirmation_link_pattern.search(
|
assert match is not None
|
||||||
message.body).groups()[0]
|
[confirmation_url] = match.groups()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Couldn't find a confirmation email.")
|
raise AssertionError("Couldn't find a confirmation email.")
|
||||||
@@ -3827,9 +3828,9 @@ class UserSignUpTest(InviteUserBase):
|
|||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
for message in reversed(outbox):
|
for message in reversed(outbox):
|
||||||
if email in message.to:
|
if email in message.to:
|
||||||
confirmation_link_pattern = re.compile(settings.EXTERNAL_HOST + r"(\S+)>")
|
match = re.search(settings.EXTERNAL_HOST + r"(\S+)>", message.body)
|
||||||
confirmation_url = confirmation_link_pattern.search(
|
assert match is not None
|
||||||
message.body).groups()[0]
|
[confirmation_url] = match.groups()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Couldn't find a confirmation email.")
|
raise AssertionError("Couldn't find a confirmation email.")
|
||||||
@@ -3882,9 +3883,9 @@ class UserSignUpTest(InviteUserBase):
|
|||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
for message in reversed(outbox):
|
for message in reversed(outbox):
|
||||||
if email in message.to:
|
if email in message.to:
|
||||||
confirmation_link_pattern = re.compile(settings.EXTERNAL_HOST + r"(\S+)>")
|
match = re.search(settings.EXTERNAL_HOST + r"(\S+)>", message.body)
|
||||||
confirmation_url = confirmation_link_pattern.search(
|
assert match is not None
|
||||||
message.body).groups()[0]
|
[confirmation_url] = match.groups()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Couldn't find a confirmation email.")
|
raise AssertionError("Couldn't find a confirmation email.")
|
||||||
@@ -3978,6 +3979,7 @@ class DeactivateUserTest(ZulipTestCase):
|
|||||||
user = self.example_user('hamlet')
|
user = self.example_user('hamlet')
|
||||||
self.assertFalse(user.is_active)
|
self.assertFalse(user.is_active)
|
||||||
password = initial_password(email)
|
password = initial_password(email)
|
||||||
|
assert password is not None
|
||||||
self.assert_login_failure(email, password=password)
|
self.assert_login_failure(email, password=password)
|
||||||
|
|
||||||
def test_do_not_deactivate_final_owner(self) -> None:
|
def test_do_not_deactivate_final_owner(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user