mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Change type of GitRelease.author to NamedUser (#969)
Github's release object in the API response contains an `author` field having a value much more like a `NamedUser` but not `GitAuthor`. e.g. https://api.github.com/repos/edhollandAL/PyGithub/releases/1210902 ``` { "id": 1210902, "author": { "login": "edhollandAL", "id": 11922660, "node_id": "MDQ6VXNlcjExOTIyNjYw", "avatar_url": "https://avatars1.githubusercontent.com/u/11922660?v=4", "gravatar_id": "", "url": "https://api.github.com/users/edhollandAL", "html_url": "https://github.com/edhollandAL", "followers_url": "https://api.github.com/users/edhollandAL/followers", "following_url": "https://api.github.com/users/edhollandAL/following{/other_user}", "gists_url": "https://api.github.com/users/edhollandAL/gists{/gist_id}", "starred_url": "https://api.github.com/users/edhollandAL/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/edhollandAL/subscriptions", "organizations_url": "https://api.github.com/users/edhollandAL/orgs", "repos_url": "https://api.github.com/users/edhollandAL/repos", "events_url": "https://api.github.com/users/edhollandAL/events{/privacy}", "received_events_url": "https://api.github.com/users/edhollandAL/received_events", "type": "User", "site_admin": false }, // (ignored) } ```
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
from os.path import basename
|
||||
import github.GithubObject
|
||||
import github.GitAuthor
|
||||
import github.NamedUser
|
||||
import github.GitReleaseAsset
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject):
|
||||
@property
|
||||
def author(self):
|
||||
"""
|
||||
:type: :class:`github.GitAuthor.GitAuthor`
|
||||
:type: :class:`github.NamedUser.NamedUser`
|
||||
"""
|
||||
self._completeIfNotSet(self._author)
|
||||
return self._author.value
|
||||
@@ -285,7 +285,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject):
|
||||
if "prerelease" in attributes:
|
||||
self._prerelease = self._makeBoolAttribute(attributes["prerelease"])
|
||||
if "author" in attributes:
|
||||
self._author = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["author"])
|
||||
self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"])
|
||||
if "url" in attributes:
|
||||
self._url = self._makeStringAttribute(attributes["url"])
|
||||
if "upload_url" in attributes:
|
||||
|
||||
@@ -73,6 +73,9 @@ class Release(Framework.TestCase):
|
||||
self.assertEqual(self.release.prerelease, False)
|
||||
self.assertEqual(self.release.url, "https://api.github.com/repos/edhollandAL/PyGithub/releases/1210814")
|
||||
self.assertEqual(self.release.author._rawData['login'], "edhollandAL")
|
||||
self.assertEqual(self.release.author.login, "edhollandAL")
|
||||
self.assertEqual(self.release.author.id, 11922660)
|
||||
self.assertEqual(self.release.author.type, "User")
|
||||
self.assertEqual(self.release.html_url, "https://github.com/edhollandAL/PyGithub/releases/tag/v1.25.2")
|
||||
self.assertEqual(self.release.created_at, datetime.datetime(2014, 10, 8, 1, 54))
|
||||
self.assertEqual(self.release.published_at, datetime.datetime(2015, 4, 24, 8, 36, 51))
|
||||
|
||||
Reference in New Issue
Block a user