From aca50a7581d32ac8bf8256bd74e053071fe7eae7 Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 25 Nov 2018 09:56:38 +0800 Subject: [PATCH] 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) } ``` --- github/GitRelease.py | 6 +++--- github/tests/GitRelease.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/github/GitRelease.py b/github/GitRelease.py index 831337a3..427dc8ea 100644 --- a/github/GitRelease.py +++ b/github/GitRelease.py @@ -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: diff --git a/github/tests/GitRelease.py b/github/tests/GitRelease.py index 18a7a4a6..d6ab7bb4 100644 --- a/github/tests/GitRelease.py +++ b/github/tests/GitRelease.py @@ -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))