From c76e67b73709d3e5a5941fec04c96e27ae428f16 Mon Sep 17 00:00:00 2001 From: Daniel Kesler Date: Wed, 21 Mar 2018 01:23:56 -0500 Subject: [PATCH] added tarball_url, zipball_url, prerelease and draft property (#522) * added tarball_url, zipball_url, prerelease and draft property to GitRelease * Add tests for new attributes --- github/GitRelease.py | 42 ++++++++++++++++++++++++++++++++++++++ github/tests/GitRelease.py | 2 ++ 2 files changed, 44 insertions(+) diff --git a/github/GitRelease.py b/github/GitRelease.py index 1bf595d2..8ee92ed0 100644 --- a/github/GitRelease.py +++ b/github/GitRelease.py @@ -141,6 +141,38 @@ class GitRelease(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._html_url) return self._html_url.value + @property + def tarball_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._tarball_url) + return self._tarball_url.value + + @property + def zipball_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._zipball_url) + return self._zipball_url.value + + @property + def prerelease(self): + """ + :type: string + """ + self._completeIfNotSet(self._prerelease) + return self._prerelease.value + + @property + def draft(self): + """ + :type: string + """ + self._completeIfNotSet(self._draft) + return self._draft.value + def delete_release(self): headers, data = self._requester.requestJsonAndCheck( "DELETE", @@ -208,6 +240,8 @@ class GitRelease(github.GithubObject.CompletableGithubObject): self._html_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._published_at = github.GithubObject.NotSet + self._tarball_url = github.GithubObject.NotSet + self._zipball_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: @@ -230,7 +264,15 @@ class GitRelease(github.GithubObject.CompletableGithubObject): self._upload_url = self._makeStringAttribute(attributes["upload_url"]) if "html_url" in attributes: self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "prerelease" in attributes: + self._prerelease = self._makeBoolAttribute(attributes["prerelease"]) + if "draft" in attributes: + self._draft = self._makeBoolAttribute(attributes["draft"]) if "created_at" in attributes: self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "published_at" in attributes: self._published_at = self._makeDatetimeAttribute(attributes["published_at"]) + if "tarball_url" in attributes: + self._tarball_url = self._makeStringAttribute(attributes["tarball_url"]) + if "zipball_url" in attributes: + self._zipball_url = self._makeStringAttribute(attributes["zipball_url"]) diff --git a/github/tests/GitRelease.py b/github/tests/GitRelease.py index c1859877..0dc9f80f 100644 --- a/github/tests/GitRelease.py +++ b/github/tests/GitRelease.py @@ -72,6 +72,8 @@ class Release(Framework.TestCase): 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)) + self.assertEqual(self.release.tarball_url, "https://api.github.com/repos/edhollandAL/PyGithub/tarball/v1.25.2") + self.assertEqual(self.release.zipball_url, "https://api.github.com/repos/edhollandAL/PyGithub/zipball/v1.25.2") # test __repr__() based on this attributes self.assertEqual(self.release.__repr__(), 'GitRelease(title="Test")')