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:
Tim Abbott
2016-06-27 11:45:41 -07:00
parent 4cac7bbb32
commit f7e87bc1f0
2 changed files with 6 additions and 3 deletions

View File

@@ -256,10 +256,13 @@ class AuthedTestCase(TestCase):
return self.client.post('/accounts/login/',
{'username': email, 'password': password})
def login(self, email, password=None):
def login(self, email, password=None, fails=False):
if password is None:
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"):
# type: (text_type, text_type, text_type) -> HttpResponse