tests: Limit email-based logins.

We now have this API...

If you really just need to log in
and not do anything with the actual
user:

    self.login('hamlet')

If you're gonna use the user in the
rest of the test:

    hamlet = self.example_user('hamlet')
    self.login_user(hamlet)

If you are specifically testing
email/password logins (used only in 4 places):

    self.login_by_email(email, password)

And for failures uses this (used twice):

    self.assert_login_failure(email)
This commit is contained in:
Steve Howell
2020-03-06 17:40:46 +00:00
committed by Tim Abbott
parent c235333041
commit 1b16693526
55 changed files with 1071 additions and 1149 deletions

View File

@@ -63,8 +63,8 @@ class TornadoWebTestCase(AsyncHTTPTestCase, ZulipTestCase):
self.set_http_headers(kwargs)
self.fetch_async('GET', path, **kwargs)
def login(self, *args: Any, **kwargs: Any) -> None:
super().login(*args, **kwargs)
def login_user(self, *args: Any, **kwargs: Any) -> None:
super().login_user(*args, **kwargs)
session_cookie = settings.SESSION_COOKIE_NAME
session_key = self.client.session.session_key
self.session_cookie = {
@@ -91,13 +91,13 @@ class TornadoWebTestCase(AsyncHTTPTestCase, ZulipTestCase):
class EventsTestCase(TornadoWebTestCase):
def test_create_queue(self) -> None:
self.login(self.example_email('hamlet'))
self.login_user(self.example_user('hamlet'))
queue_id = self.create_queue()
self.assertIn(queue_id, event_queue.clients)
def test_events_async(self) -> None:
user_profile = self.example_user('hamlet')
self.login(user_profile.email)
self.login_user(user_profile)
event_queue_id = self.create_queue()
data = {
'queue_id': event_queue_id,