tests: Use get_account_data_dict helper in some github tests.

The helper should be used instead of constructing the dict manually.

Change get_account_data_dict, on GitHubAuthBackendTest
class, so it has a third argument, user_avatar_url.

This is a preparation for support using GitHub avatar
upon user resgistration (when the user logs using
GitHub).
This commit is contained in:
Clara Dantas 2020-06-24 23:34:41 -03:00 committed by Tim Abbott
parent 35378d4660
commit d2da9827ac
1 changed files with 9 additions and 9 deletions

View File

@ -2392,8 +2392,8 @@ class GitHubAuthBackendTest(SocialAuthBase):
self.email_data = email_data
def get_account_data_dict(self, email: str, name: str) -> Dict[str, Any]:
return dict(email=email, name=name)
def get_account_data_dict(self, email: str, name: str, user_avatar_url: str='') -> Dict[str, Any]:
return dict(email=email, name=name, user_avatar_url=user_avatar_url)
def test_social_auth_email_not_verified(self) -> None:
account_data_dict = self.get_account_data_dict(email=self.email, name=self.name)
@ -2472,7 +2472,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
self.assertTrue(github_auth_enabled())
def test_github_oauth2_success_non_primary(self) -> None:
account_data_dict = dict(email='nonprimary@zulip.com', name="Non Primary")
account_data_dict = self.get_account_data_dict(email='nonprimary@zulip.com', name="Non Primary")
email_data = [
dict(email=account_data_dict["email"],
verified=True),
@ -2502,7 +2502,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
# If the user has a single email associated with its GitHub account,
# the choose email screen should not be shown and the first email
# should be used for user's signup/login.
account_data_dict = dict(email='not-hamlet@zulip.com', name=self.name)
account_data_dict = self.get_account_data_dict(email='not-hamlet@zulip.com', name=self.name)
email_data = [
dict(email='hamlet@zulip.com',
verified=True,
@ -2558,7 +2558,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
# are associated with existing accounts, we expect the choose
# email screen to select which account to use.
hamlet = self.example_user("hamlet")
account_data_dict = dict(email='hamlet@zulip.com', name="Hamlet")
account_data_dict = self.get_account_data_dict(email='hamlet@zulip.com', name="Hamlet")
email_data = [
dict(email=account_data_dict["email"],
verified=True),
@ -2589,7 +2589,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
# none of which are associated with an existing account, the
# choose email screen should be shown (which will lead to a
# "continue to registration" choice).
account_data_dict = dict(email="not-hamlet@zulip.com", name="Not Hamlet")
account_data_dict = self.get_account_data_dict(email="not-hamlet@zulip.com", name="Not Hamlet")
email_data = [
dict(email=account_data_dict["email"],
verified=True),
@ -2668,7 +2668,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
# As emails ending with `noreply.github.com` are excluded from
# verified_emails, choosing it as an email should raise a `email
# not associated` warning.
account_data_dict = dict(email="hamlet@users.noreply.github.com", name=self.name)
account_data_dict = self.get_account_data_dict(email="hamlet@users.noreply.github.com", name=self.name)
email_data = [
dict(email="notprimary@zulip.com",
verified=True),
@ -2694,7 +2694,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
)])
def test_github_oauth2_email_not_associated(self) -> None:
account_data_dict = dict(email='not-associated@zulip.com', name=self.name)
account_data_dict = self.get_account_data_dict(email='not-associated@zulip.com', name=self.name)
email_data = [
dict(email='nonprimary@zulip.com',
verified=True),
@ -2721,7 +2721,7 @@ class GitHubAuthBackendTest(SocialAuthBase):
# check if a user is denied to login if the user manages to
# send an unverified email that has an existing account in
# organisation through `email` GET parameter.
account_data_dict = dict(email='hamlet@zulip.com', name=self.name)
account_data_dict = self.get_account_data_dict(email='hamlet@zulip.com', name=self.name)
email_data = [
dict(email='iago@zulip.com',
verified=True),