From 1f98067e9567ed5acfac3e5585862fef089e47fc Mon Sep 17 00:00:00 2001 From: Michael Stead Date: Mon, 27 May 2013 14:13:14 -0300 Subject: [PATCH 1/2] Add html_url attribute to comments. html_url attributes were missing from IssueComment and PullRequestComment. Added to both as per the GitHub API. --- github/IssueComment.py | 12 ++++++++++++ github/PullRequestComment.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/github/IssueComment.py b/github/IssueComment.py index 4998888e..b96417e0 100644 --- a/github/IssueComment.py +++ b/github/IssueComment.py @@ -64,6 +64,14 @@ class IssueComment(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._url) return self._NoneIfNotSet(self._url) + @property + def html_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._html_url) + return self._NoneIfNotSet(self._html_url) + @property def user(self): """ @@ -108,6 +116,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject): self._id = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet + self._html_url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): @@ -126,6 +135,9 @@ class IssueComment(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] self._url = attributes["url"] + if "html_url" in attributes: # pragma no branch + assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] + self._html_url = attributes["html_url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py index 176e1350..748ab5b2 100644 --- a/github/PullRequestComment.py +++ b/github/PullRequestComment.py @@ -104,6 +104,14 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._url) return self._NoneIfNotSet(self._url) + @property + def html_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._html_url) + return self._NoneIfNotSet(self._html_url) + @property def user(self): """ @@ -153,6 +161,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): self._position = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet + self._html_url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): @@ -186,6 +195,9 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): if "url" in attributes: # pragma no branch assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] self._url = attributes["url"] + if "html_url" in attributes: # pragma no branch + assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] + self._html_url = attributes["html_url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) From c93e4b8ff4da178b74c7a159dfcc1ae4fea98af6 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 31 May 2013 13:48:02 +0200 Subject: [PATCH 2/2] Add tests for html_url for Issue and PullComment (#170) I just modified the ReplayData manually and added a "get" in the tests. --- github/tests/IssueComment.py | 1 + github/tests/PullRequestComment.py | 1 + github/tests/ReplayData/IssueComment.setUp.txt | 2 +- github/tests/ReplayData/PullRequestComment.setUp.txt | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/github/tests/IssueComment.py b/github/tests/IssueComment.py index e4827aca..bac3e820 100644 --- a/github/tests/IssueComment.py +++ b/github/tests/IssueComment.py @@ -31,6 +31,7 @@ class IssueComment(Framework.TestCase): self.assertEqual(self.comment.updated_at, datetime.datetime(2012, 5, 20, 11, 46, 42)) self.assertEqual(self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311") self.assertEqual(self.comment.user.login, "jacquev6") + self.assertEqual(self.comment.html_url, "https://github.com/jacquev6/PyGithub/issues/28#issuecomment-5808311") def testEdit(self): self.comment.edit("Comment edited by PyGithub") diff --git a/github/tests/PullRequestComment.py b/github/tests/PullRequestComment.py index 809662fd..d744cfbe 100644 --- a/github/tests/PullRequestComment.py +++ b/github/tests/PullRequestComment.py @@ -36,6 +36,7 @@ class PullRequestComment(Framework.TestCase): self.assertEqual(self.comment.updated_at, datetime.datetime(2012, 5, 27, 9, 40, 12)) self.assertEqual(self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298") self.assertEqual(self.comment.user.login, "jacquev6") + self.assertEqual(self.comment.html_url, "https://github.com/jacquev6/PyGithub/pull/170#issuecomment-18637907") def testEdit(self): self.comment.edit("Comment edited by PyGithub") diff --git a/github/tests/ReplayData/IssueComment.setUp.txt b/github/tests/ReplayData/IssueComment.setUp.txt index aae81fdc..01562914 100644 --- a/github/tests/ReplayData/IssueComment.setUp.txt +++ b/github/tests/ReplayData/IssueComment.setUp.txt @@ -40,5 +40,5 @@ None null 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '506'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4fa1a8e8e534bcc93123ea6ee8fd4284"'), ('date', 'Sun, 20 May 2012 11:50:56 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"updated_at":"2012-05-20T11:46:42Z","body":"Comment created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311","created_at":"2012-05-20T11:46:42Z","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146},"id":5808311} +{"updated_at":"2012-05-20T11:46:42Z","body":"Comment created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311","created_at":"2012-05-20T11:46:42Z","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146},"id":5808311,"html_url":"https://github.com/jacquev6/PyGithub/issues/28#issuecomment-5808311"} diff --git a/github/tests/ReplayData/PullRequestComment.setUp.txt b/github/tests/ReplayData/PullRequestComment.setUp.txt index 70f2ce8f..874c817a 100644 --- a/github/tests/ReplayData/PullRequestComment.setUp.txt +++ b/github/tests/ReplayData/PullRequestComment.setUp.txt @@ -40,5 +40,5 @@ None null 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('content-length', '937'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c05c16826ff8762adedb7757f916d5de"'), ('date', 'Sun, 27 May 2012 10:04:37 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"updated_at":"2012-05-27T09:40:12Z","position":5,"original_position":5,"body":"Comment created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298","commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","_links":{"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298"},"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31#r886298"},"pull_request":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"}},"created_at":"2012-05-27T09:40:12Z","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"original_commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","path":"src/github/Issue.py","id":886298} +{"updated_at":"2012-05-27T09:40:12Z","position":5,"original_position":5,"body":"Comment created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298","commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","_links":{"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298"},"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31#r886298"},"pull_request":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"}},"created_at":"2012-05-27T09:40:12Z","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"original_commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","path":"src/github/Issue.py","id":886298,"html_url":"https://github.com/jacquev6/PyGithub/pull/170#issuecomment-18637907"}