diff --git a/github/PullRequest.py b/github/PullRequest.py index 1e7b3c83..823a0291 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -63,6 +63,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._assignee) return self._assignee.value + @property + def assignees(self): + """ + :type: list of :class:`github.NamedUser.NamedUser` + """ + self._completeIfNotSet(self._assignees) + return self._assignees.value + @property def base(self): """ @@ -518,6 +526,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): def _initAttributes(self): self._additions = github.GithubObject.NotSet self._assignee = github.GithubObject.NotSet + self._assignees = github.GithubObject.NotSet self._base = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._changed_files = github.GithubObject.NotSet @@ -556,6 +565,13 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._additions = self._makeIntAttribute(attributes["additions"]) if "assignee" in attributes: # pragma no branch self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"]) + if "assignees" in attributes: # pragma no branch + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, attributes["assignees"]) + elif "assignee" in attributes: + if attributes["assignee"] is not None: + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, [attributes["assignee"]]) + else: + self._assignees = self._makeListOfClassesAttribute(github.NamedUser.NamedUser, []) if "base" in attributes: # pragma no branch self._base = self._makeClassAttribute(github.PullRequestPart.PullRequestPart, attributes["base"]) if "body" in attributes: # pragma no branch diff --git a/github/tests/PullRequest.py b/github/tests/PullRequest.py index d4923978..bf360860 100644 --- a/github/tests/PullRequest.py +++ b/github/tests/PullRequest.py @@ -38,6 +38,7 @@ class PullRequest(Framework.TestCase): def testAttributes(self): self.assertEqual(self.pull.additions, 511) self.assertEqual(self.pull.assignee.login, "jacquev6") + self.assertListKeyEqual(self.pull.assignees, lambda a: a.login, ["stuglaser", "jacquev6"]) self.assertEqual(self.pull.base.label, "jacquev6:topic/RewriteWithGeneratedCode") self.assertEqual(self.pull.base.sha, "ed866fc43833802ab553e5ff8581c81bb00dd433") self.assertEqual(self.pull.base.user.login, "jacquev6") diff --git a/github/tests/ReplayData/PullRequest.setUp.txt b/github/tests/ReplayData/PullRequest.setUp.txt index 53ebaac0..d368fd18 100644 --- a/github/tests/ReplayData/PullRequest.setUp.txt +++ b/github/tests/ReplayData/PullRequest.setUp.txt @@ -29,5 +29,5 @@ None null 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '4182'), ('server', 'nginx'), ('last-modified', 'Sat, 03 Nov 2012 08:19:40 GMT'), ('connection', 'keep-alive'), ('etag', '"1ec7d9f2ebb27db7dc002f1382d23975"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Sat, 03 Nov 2012 08:19:46 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"additions":511,"deletions":384,"merged_at":"2012-05-27T10:29:07Z","base":{"label":"jacquev6:topic/RewriteWithGeneratedCode","repo":{"watchers":97,"pushed_at":"2012-11-03T08:07:38Z","watchers_count":97,"forks":27,"open_issues":12,"mirror_url":null,"description":"Python library implementing the full Github API v3","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"open_issues_count":12,"url":"https://api.github.com/repos/jacquev6/PyGithub","updated_at":"2012-11-03T08:07:40Z","html_url":"https://github.com/jacquev6/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","language":"Python","has_downloads":true,"ssh_url":"git@github.com:jacquev6/PyGithub.git","size":256,"forks_count":27,"fork":false,"full_name":"jacquev6/PyGithub","name":"PyGithub","created_at":"2012-02-25T12:53:47Z","git_url":"git://github.com/jacquev6/PyGithub.git","svn_url":"https://github.com/jacquev6/PyGithub","homepage":"http://vincent-jacques.net/PyGithub","has_wiki":true,"private":false,"id":3544490,"has_issues":true},"sha":"ed866fc43833802ab553e5ff8581c81bb00dd433","ref":"topic/RewriteWithGeneratedCode","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146}},"review_comments":1,"changed_files":45,"merge_commit_sha":"28ae6dd10ebccd5eaf8db8dacb5b699ee7f4a663","closed_at":"2012-05-27T10:29:07Z","number":31,"issue_url":"https://github.com/jacquev6/PyGithub/issues/31","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31","milestone":null,"updated_at":"2012-11-03T08:19:40Z","patch_url":"https://github.com/jacquev6/PyGithub/pull/31.patch","html_url":"https://github.com/jacquev6/PyGithub/pull/31","merged_by":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"commits":3,"state":"closed","mergeable":false,"_links":{"review_comments":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31/comments"},"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31"},"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"},"issue":{"href":"https://api.github.com/repos/jacquev6/PyGithub/issues/31"},"comments":{"href":"https://api.github.com/repos/jacquev6/PyGithub/issues/31/comments"}},"head":{"label":"BeaverSoftware:master","repo":null,"sha":"8a4f306d4b223682dd19410d4a9150636ebe4206","ref":"master","user":{"url":"https://api.github.com/users/BeaverSoftware","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png","login":"BeaverSoftware","id":1424031}},"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"diff_url":"https://github.com/jacquev6/PyGithub/pull/31.diff","comments":1,"created_at":"2012-05-27T09:25:36Z","id":1436215,"merged":true,"mergeable_state":"dirty","body":"Body edited by PyGithub","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"title":"Title edited by PyGithub"} +{"additions":511,"deletions":384,"merged_at":"2012-05-27T10:29:07Z","base":{"label":"jacquev6:topic/RewriteWithGeneratedCode","repo":{"watchers":97,"pushed_at":"2012-11-03T08:07:38Z","watchers_count":97,"forks":27,"open_issues":12,"mirror_url":null,"description":"Python library implementing the full Github API v3","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"open_issues_count":12,"url":"https://api.github.com/repos/jacquev6/PyGithub","updated_at":"2012-11-03T08:07:40Z","html_url":"https://github.com/jacquev6/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","language":"Python","has_downloads":true,"ssh_url":"git@github.com:jacquev6/PyGithub.git","size":256,"forks_count":27,"fork":false,"full_name":"jacquev6/PyGithub","name":"PyGithub","created_at":"2012-02-25T12:53:47Z","git_url":"git://github.com/jacquev6/PyGithub.git","svn_url":"https://github.com/jacquev6/PyGithub","homepage":"http://vincent-jacques.net/PyGithub","has_wiki":true,"private":false,"id":3544490,"has_issues":true},"sha":"ed866fc43833802ab553e5ff8581c81bb00dd433","ref":"topic/RewriteWithGeneratedCode","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146}},"review_comments":1,"changed_files":45,"merge_commit_sha":"28ae6dd10ebccd5eaf8db8dacb5b699ee7f4a663","closed_at":"2012-05-27T10:29:07Z","number":31,"issue_url":"https://github.com/jacquev6/PyGithub/issues/31","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31","milestone":null,"updated_at":"2012-11-03T08:19:40Z","patch_url":"https://github.com/jacquev6/PyGithub/pull/31.patch","html_url":"https://github.com/jacquev6/PyGithub/pull/31","merged_by":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"commits":3,"state":"closed","mergeable":false,"_links":{"review_comments":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31/comments"},"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31"},"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"},"issue":{"href":"https://api.github.com/repos/jacquev6/PyGithub/issues/31"},"comments":{"href":"https://api.github.com/repos/jacquev6/PyGithub/issues/31/comments"}},"head":{"label":"BeaverSoftware:master","repo":null,"sha":"8a4f306d4b223682dd19410d4a9150636ebe4206","ref":"master","user":{"url":"https://api.github.com/users/BeaverSoftware","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png","login":"BeaverSoftware","id":1424031}},"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"assignees":[{"url":"https://api.github.com/users/stuglaser","gravatar_id":"","avatar_url":"https://avatars.githubusercontent.com/u/1527117?v=3","login":"stuglaser","id":1527117},{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146}],"diff_url":"https://github.com/jacquev6/PyGithub/pull/31.diff","comments":1,"created_at":"2012-05-27T09:25:36Z","id":1436215,"merged":true,"mergeable_state":"dirty","body":"Body edited by PyGithub","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","id":327146},"title":"Title edited by PyGithub"}