-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync NamedUser class with API spec (#3149)
Adds the following attributes: - display_login - notification_email - role_name - score - starred_at - text_matches - user_view_type
- Loading branch information
Showing
4 changed files
with
110 additions
and
49 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 |
---|---|---|
|
@@ -38,6 +38,8 @@ | |
# # | ||
################################################################################ | ||
|
||
from __future__ import annotations | ||
|
||
from datetime import datetime, timezone | ||
|
||
from . import Framework | ||
|
@@ -48,6 +50,62 @@ def setUp(self): | |
super().setUp() | ||
self.user = self.g.get_user("jacquev6") | ||
|
||
def testAttributes(self): | ||
self.assertEqual(self.user.avatar_url, "https://avatars.githubusercontent.com/u/327146?v=4") | ||
self.assertIsNone(self.user.bio) | ||
self.assertEqual(self.user.blog, "http://vincent-jacques.net") | ||
self.assertIsNone(self.user.collaborators) | ||
self.assertIsNone(self.user.company) | ||
self.assertIsNone(self.user.contributions) | ||
self.assertEqual(self.user.created_at, datetime(2010, 7, 9, 6, 10, 6, tzinfo=timezone.utc)) | ||
self.assertIsNone(self.user.disk_usage) | ||
self.assertIsNone(self.user.display_login) | ||
self.assertEqual(self.user.email, "[email protected]") | ||
self.assertEqual(self.user.events_url, "https://api.github.com/users/jacquev6/events{/privacy}") | ||
self.assertEqual(self.user.followers, 98) | ||
self.assertEqual(self.user.followers_url, "https://api.github.com/users/jacquev6/followers") | ||
self.assertEqual(self.user.following, 62) | ||
self.assertEqual(self.user.following_url, "https://api.github.com/users/jacquev6/following{/other_user}") | ||
self.assertEqual(self.user.gists_url, "https://api.github.com/users/jacquev6/gists{/gist_id}") | ||
self.assertEqual(self.user.gravatar_id, "") | ||
self.assertTrue(self.user.hireable) | ||
self.assertEqual(self.user.html_url, "https://github.com/jacquev6") | ||
self.assertEqual(self.user.id, 327146) | ||
self.assertEqual(self.user.location, "France") | ||
self.assertEqual(self.user.login, "jacquev6") | ||
self.assertEqual(self.user.name, "Vincent Jacques") | ||
self.assertEqual(self.user.node_id, "MDQ6VXNlcjMyNzE0Ng==") | ||
self.assertIsNone(self.user.notification_email) | ||
self.assertEqual(self.user.organizations_url, "https://api.github.com/users/jacquev6/orgs") | ||
self.assertIsNone(self.user.owned_private_repos) | ||
self.assertIsNone(self.user.permissions) | ||
self.assertIsNone(self.user.plan) | ||
self.assertIsNone(self.user.plan) | ||
self.assertIsNone(self.user.plan) | ||
self.assertIsNone(self.user.plan) | ||
self.assertIsNone(self.user.private_gists) | ||
self.assertEqual(self.user.public_gists, 18) | ||
self.assertEqual(self.user.public_repos, 38) | ||
self.assertEqual(self.user.received_events_url, "https://api.github.com/users/jacquev6/received_events") | ||
self.assertEqual(self.user.repos_url, "https://api.github.com/users/jacquev6/repos") | ||
self.assertIsNone(self.user.role_name) | ||
self.assertEqual(self.user.score, None) | ||
self.assertEqual(self.user.site_admin, False) | ||
self.assertIsNone(self.user.starred_at) | ||
self.assertEqual(self.user.starred_url, "https://api.github.com/users/jacquev6/starred{/owner}{/repo}") | ||
self.assertEqual(self.user.subscriptions_url, "https://api.github.com/users/jacquev6/subscriptions") | ||
self.assertIsNone(self.user.suspended_at) | ||
self.assertIsNone(self.user.text_matches) | ||
self.assertIsNone(self.user.total_private_repos) | ||
self.assertIsNone(self.user.twitter_username) | ||
self.assertEqual(self.user.type, "User") | ||
self.assertEqual(self.user.updated_at, datetime(2024, 10, 20, 7, 14, 52, tzinfo=timezone.utc)) | ||
self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6") | ||
self.assertEqual(self.user.node_id, "MDQ6VXNlcjMyNzE0Ng==") | ||
self.assertEqual(repr(self.user), 'NamedUser(login="jacquev6")') | ||
self.assertEqual(repr(self.user.plan), "None") | ||
self.assertEqual(self.user.user_view_type, "public") | ||
|
||
def testAttributesOfOtherUser(self): | ||
self.user = self.g.get_user("nvie") | ||
self.assertEqual( | ||
|
@@ -86,50 +144,6 @@ def testAttributesOfOtherUser(self): | |
self.assertEqual(self.user.node_id, "MDQ6VXNlcjgzODQ0") | ||
self.assertEqual(repr(self.user), 'NamedUser(login="nvie")') | ||
|
||
def testAttributesOfSelf(self): | ||
self.assertEqual( | ||
self.user.avatar_url, | ||
"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", | ||
) | ||
self.assertEqual(self.user.bio, "") | ||
self.assertEqual(self.user.blog, "http://vincent-jacques.net") | ||
self.assertEqual(self.user.collaborators, 0) | ||
self.assertEqual(self.user.company, "Criteo") | ||
self.assertEqual( | ||
self.user.created_at, | ||
datetime(2010, 7, 9, 6, 10, 6, tzinfo=timezone.utc), | ||
) | ||
self.assertEqual(self.user.disk_usage, 17080) | ||
self.assertEqual(self.user.email, "[email protected]") | ||
self.assertEqual(self.user.followers, 13) | ||
self.assertEqual(self.user.following, 24) | ||
self.assertEqual(self.user.gravatar_id, "b68de5ae38616c296fa345d2b9df2225") | ||
self.assertFalse(self.user.hireable) | ||
self.assertEqual(self.user.html_url, "https://github.com/jacquev6") | ||
self.assertEqual(self.user.id, 327146) | ||
self.assertEqual(self.user.location, "Paris, France") | ||
self.assertEqual(self.user.login, "jacquev6") | ||
self.assertEqual(self.user.name, "Vincent Jacques") | ||
self.assertEqual(self.user.owned_private_repos, 5) | ||
self.assertEqual(self.user.plan.name, "micro") | ||
self.assertEqual(self.user.plan.collaborators, 1) | ||
self.assertEqual(self.user.plan.space, 614400) | ||
self.assertEqual(self.user.plan.private_repos, 5) | ||
self.assertEqual(self.user.private_gists, 5) | ||
self.assertEqual(self.user.public_gists, 2) | ||
self.assertEqual(self.user.public_repos, 11) | ||
self.assertEqual( | ||
self.user.suspended_at, | ||
datetime(2013, 8, 10, 7, 11, 7, tzinfo=timezone.utc), | ||
) | ||
self.assertEqual(self.user.total_private_repos, 5) | ||
self.assertIsNone(self.user.twitter_username) | ||
self.assertEqual(self.user.type, "User") | ||
self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6") | ||
self.assertEqual(self.user.node_id, "MDQ6VXNlcjMyNzE0Ng==") | ||
self.assertEqual(repr(self.user), 'NamedUser(login="jacquev6")') | ||
self.assertEqual(repr(self.user.plan), 'Plan(name="micro")') | ||
|
||
def testGetGists(self): | ||
self.assertListKeyEqual( | ||
self.user.get_gists(), | ||
|
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 |
---|---|---|
|
@@ -6,5 +6,5 @@ None | |
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} | ||
None | ||
200 | ||
[('status', '200 OK'), ('x-ratelimit-remaining', '4960'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"2b9d2167029cc33666d02e0b0e95f2b9"'), ('date', 'Sat, 26 May 2012 11:08:21 GMT'), ('content-type', 'application/json; charset=utf-8')] | ||
{"type":"User","disk_usage":17080,"public_gists":2,"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","public_repos":11,"hireable":false,"private_gists":5,"plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"bio":"","company":"Criteo","blog":"http://vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","total_private_repos":5,"email":"[email protected]","collaborators":0,"followers":13,"name":"Vincent Jacques","owned_private_repos":5,"created_at":"2010-07-09T06:10:06Z","suspended_at":"2013-08-10T07:11:07Z","location":"Paris, France","id":327146,"following":24,"html_url":"https://github.com/jacquev6", "node_id":"MDQ6VXNlcjMyNzE0Ng=="} | ||
[('Date', 'Fri, 03 Jan 2025 22:05:16 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"cdcdd165941281cdc3948a0cdff00dcb40d91a0ba044e67272d5b433326e8f81"'), ('Last-Modified', 'Sun, 20 Oct 2024 07:14:52 GMT'), ('X-OAuth-Scopes', 'read:discussion, repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2025-02-04 16:42:10 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('x-github-api-version-selected', '2022-11-28'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4996'), ('X-RateLimit-Reset', '1735944560'), ('X-RateLimit-Used', '4'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('Transfer-Encoding', 'chunked'), ('Server', 'github.com'), ('X-GitHub-Request-Id', 'DEEE:4E297:23C6134F:24ABF6D7:67785F1C')] | ||
{"login":"jacquev6","id":327146,"node_id":"MDQ6VXNlcjMyNzE0Ng==","avatar_url":"https://avatars.githubusercontent.com/u/327146?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","user_view_type":"public","site_admin":false,"name":"Vincent Jacques","company":null,"blog":"http://vincent-jacques.net","location":"France","email":"[email protected]","hireable":true,"bio":null,"twitter_username":null,"public_repos":38,"public_gists":18,"followers":98,"following":62,"created_at":"2010-07-09T06:10:06Z","updated_at":"2024-10-20T07:14:52Z"} |
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