mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
tests: Added ZulipTestCase.example_user() function.
The example_user() function is specifically designed for AARON, hamlet, cordelia, and friends, and it allows a concise way of using their built-in user profiles. Eventually, the widespread use of example_user() should help us with refactorings such as moving the tests users out of the "zulip.com" realm and deprecating get_user_profile_by_email.
This commit is contained in:
@@ -781,7 +781,7 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest):
|
||||
self.assertEqual(query_params["realm"], ['http://zulip.testserver'])
|
||||
self.assertEqual(query_params["email"], ['hamlet@zulip.com'])
|
||||
encrypted_api_key = query_params["otp_encrypted_api_key"][0]
|
||||
self.assertEqual(get_user_profile_by_email("hamlet@zulip.com").api_key,
|
||||
self.assertEqual(self.example_user('hamlet').api_key,
|
||||
otp_decrypt_api_key(encrypted_api_key, mobile_flow_otp))
|
||||
|
||||
def test_log_into_subdomain(self):
|
||||
@@ -794,7 +794,7 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest):
|
||||
with mock.patch('zerver.views.auth.get_subdomain', return_value='zulip'):
|
||||
result = self.client_get('/accounts/login/subdomain/')
|
||||
self.assertEqual(result.status_code, 302)
|
||||
user_profile = get_user_profile_by_email('hamlet@zulip.com')
|
||||
user_profile = self.example_user('hamlet')
|
||||
self.assertEqual(get_session_dict_user(self.client.session), user_profile.id)
|
||||
|
||||
# If authenticate_remote_user detects a subdomain mismatch, then
|
||||
@@ -910,7 +910,7 @@ class GoogleLoginTest(GoogleOAuthTest):
|
||||
account_response = ResponseMock(200, account_data)
|
||||
self.google_oauth2_test(token_response, account_response)
|
||||
|
||||
user_profile = get_user_profile_by_email('hamlet@zulip.com')
|
||||
user_profile = self.example_user('hamlet')
|
||||
self.assertEqual(get_session_dict_user(self.client.session), user_profile.id)
|
||||
|
||||
def test_google_oauth2_registration(self):
|
||||
@@ -1001,7 +1001,7 @@ class GoogleLoginTest(GoogleOAuthTest):
|
||||
account_response = ResponseMock(200, account_data)
|
||||
self.google_oauth2_test(token_response, account_response)
|
||||
|
||||
user_profile = get_user_profile_by_email('hamlet@zulip.com')
|
||||
user_profile = self.example_user('hamlet')
|
||||
self.assertEqual(get_session_dict_user(self.client.session), user_profile.id)
|
||||
|
||||
def test_google_oauth2_account_response_no_email(self):
|
||||
|
||||
Reference in New Issue
Block a user