mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 14:08:23 +00:00
test_helpers: Require that login calls actually succeed.
This caught several bugs where test code wasn't doing what it's author intended.
This commit is contained in:
@@ -256,10 +256,13 @@ class AuthedTestCase(TestCase):
|
|||||||
return self.client.post('/accounts/login/',
|
return self.client.post('/accounts/login/',
|
||||||
{'username': email, 'password': password})
|
{'username': email, 'password': password})
|
||||||
|
|
||||||
def login(self, email, password=None):
|
def login(self, email, password=None, fails=False):
|
||||||
if password is None:
|
if password is None:
|
||||||
password = initial_password(email)
|
password = initial_password(email)
|
||||||
self.client.login(username=email, password=password)
|
if not fails:
|
||||||
|
self.assertTrue(self.client.login(username=email, password=password))
|
||||||
|
else:
|
||||||
|
self.assertFalse(self.client.login(username=email, password=password))
|
||||||
|
|
||||||
def register(self, username, password, domain="zulip.com"):
|
def register(self, username, password, domain="zulip.com"):
|
||||||
# type: (text_type, text_type, text_type) -> HttpResponse
|
# type: (text_type, text_type, text_type) -> HttpResponse
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class LoginTest(AuthedTestCase):
|
|||||||
|
|
||||||
def test_login_bad_password(self):
|
def test_login_bad_password(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
self.login("hamlet@zulip.com", "wrongpassword")
|
self.login("hamlet@zulip.com", password="wrongpassword", fails=True)
|
||||||
self.assertIsNone(get_session_dict_user(self.client.session))
|
self.assertIsNone(get_session_dict_user(self.client.session))
|
||||||
|
|
||||||
def test_login_nonexist_user(self):
|
def test_login_nonexist_user(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user