-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,10 @@ class GitHubTests(OAuth2TestsMixin, TestCase): | |
provider_id = GitHubProvider.id | ||
|
||
def get_mocked_response(self): | ||
return MockedResponse( | ||
200, | ||
""" | ||
return [ | ||
MockedResponse( | ||
200, | ||
""" | ||
{ | ||
"type":"User", | ||
"organizations_url":"https://api.github.com/users/pennersr/orgs", | ||
|
@@ -42,19 +43,52 @@ def get_mocked_response(self): | |
"events_url":"https://api.github.com/users/pennersr/events{/privacy}", | ||
"following_url":"https://api.github.com/users/pennersr/following" | ||
}""", | ||
) | ||
), | ||
MockedResponse( | ||
200, | ||
""" | ||
{ | ||
"email": "[email protected]", | ||
"verified": true, | ||
"primary": true, | ||
"visibility": "public" | ||
} | ||
""", | ||
), | ||
] | ||
|
||
def test_account_name_null(self): | ||
"""String conversion when GitHub responds with empty name""" | ||
data = """{ | ||
mocks = [ | ||
MockedResponse( | ||
200, | ||
""" | ||
{ | ||
"type": "User", | ||
"id": 201022, | ||
"login": "pennersr", | ||
"name": null | ||
}""" | ||
self.login(MockedResponse(200, data)) | ||
} | ||
""", | ||
), | ||
MockedResponse( | ||
200, | ||
""" | ||
[ | ||
{ | ||
"email": "[email protected]", | ||
"verified": true, | ||
"primary": true, | ||
"visibility": "public" | ||
} | ||
] | ||
""", | ||
), | ||
] | ||
self.login(mocks) | ||
socialaccount = SocialAccount.objects.get(uid="201022") | ||
self.assertIsNone(socialaccount.extra_data.get("name")) | ||
account = socialaccount.get_provider_account() | ||
self.assertIsNotNone(account.to_str()) | ||
self.assertEqual(account.to_str(), "pennersr") | ||
self.assertEqual(socialaccount.user.email, "[email protected]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters