diff --git a/github/PullRequest.py b/github/PullRequest.py index 61ceea0f..ec86eab5 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -17,6 +17,7 @@ # Copyright 2018 Gilad Shefer # # Copyright 2018 Thibault Jamet # # Copyright 2018 sfdye # +# Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # @@ -36,6 +37,7 @@ # # ################################################################################ +import urllib import github.GithubObject import github.PaginatedList @@ -202,6 +204,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._issue_url) return self._issue_url.value + @property + def labels(self): + """ + :type: list of :class:`github.Label.Label` + """ + self._completeIfNotSet(self._labels) + return self._labels.value + @property def merge_commit_sha(self): """ @@ -607,6 +617,72 @@ class PullRequest(github.GithubObject.CompletableGithubObject): list_item='users' ) + def get_labels(self): + """ + :calls: `GET /repos/:owner/:repo/pulls/:number/labels `_ + :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` + """ + return github.PaginatedList.PaginatedList( + github.Label.Label, + self._requester, + self.url + "/labels", + None + ) + + def add_to_labels(self, *labels): + """ + :calls: `POST /repos/:owner/:repo/pulls/:number/labels `_ + :param label: :class:`github.Label.Label` or string + :rtype: None + """ + assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels + post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] + headers, data = self._requester.requestJsonAndCheck( + "POST", + self.url + "/labels", + input=post_parameters + ) + + def delete_labels(self): + """ + :calls: `DELETE /repos/:owner/:repo/pulls/:number/labels `_ + :rtype: None + """ + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + self.url + "/labels" + ) + + def remove_from_labels(self, label): + """ + :calls: `DELETE /repos/:owner/:repo/pulls/:number/labels/:name `_ + :param label: :class:`github.Label.Label` or string + :rtype: None + """ + assert isinstance(label, (github.Label.Label, str, unicode)), label + if isinstance(label, github.Label.Label): + label = label._identity + else: + label = urllib.quote(label) + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + self.url + "/labels/" + label + ) + + def set_labels(self, *labels): + """ + :calls: `PUT /repos/:owner/:repo/pulls/:number/labels `_ + :param label: :class:`github.Label.Label` + :rtype: None + """ + assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels + post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] + headers, data = self._requester.requestJsonAndCheck( + "PUT", + self.url + "/labels", + input=post_parameters + ) + def is_merged(self): """ :calls: `GET /repos/:owner/:repo/pulls/:number/merge `_ @@ -663,6 +739,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._issue_url = github.GithubObject.NotSet + self._labels = github.GithubObject.NotSet self._merge_commit_sha = github.GithubObject.NotSet self._mergeable = github.GithubObject.NotSet self._mergeable_state = github.GithubObject.NotSet @@ -723,6 +800,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._id = self._makeIntAttribute(attributes["id"]) if "issue_url" in attributes: # pragma no branch self._issue_url = self._makeStringAttribute(attributes["issue_url"]) + if "labels" in attributes: # pragma no branch + self._labels = self._makeListOfClassesAttribute(github.Label.Label, attributes["labels"]) if "merge_commit_sha" in attributes: # pragma no branch self._merge_commit_sha = self._makeStringAttribute(attributes["merge_commit_sha"]) if "mergeable" in attributes: # pragma no branch diff --git a/github/tests/PullRequest.py b/github/tests/PullRequest.py index c74f877e..52f96879 100644 --- a/github/tests/PullRequest.py +++ b/github/tests/PullRequest.py @@ -10,6 +10,7 @@ # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 sfdye # +# Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # @@ -61,6 +62,7 @@ class PullRequest(Framework.TestCase): self.assertEqual(self.pull.html_url, "https://github.com/jacquev6/PyGithub/pull/31") self.assertEqual(self.pull.id, 1436215) self.assertEqual(self.pull.issue_url, "https://github.com/jacquev6/PyGithub/issues/31") + self.assertListKeyEqual(self.pull.labels, lambda a: a.name, ["refactoring"]) self.assertFalse(self.pull.mergeable) self.assertTrue(self.pull.merged) self.assertEqual(self.pull.merged_at, datetime.datetime(2012, 5, 27, 10, 29, 7)) @@ -111,6 +113,49 @@ class PullRequest(Framework.TestCase): def testGetFiles(self): self.assertListKeyEqual(self.pull.get_files(), lambda f: f.filename, ["codegen/templates/GithubObject.py", "src/github/AuthenticatedUser.py", "src/github/Authorization.py", "src/github/Branch.py", "src/github/Commit.py", "src/github/CommitComment.py", "src/github/CommitFile.py", "src/github/CommitStats.py", "src/github/Download.py", "src/github/Event.py", "src/github/Gist.py", "src/github/GistComment.py", "src/github/GistHistoryState.py", "src/github/GitAuthor.py", "src/github/GitBlob.py", "src/github/GitCommit.py", "src/github/GitObject.py", "src/github/GitRef.py", "src/github/GitTag.py", "src/github/GitTree.py", "src/github/GitTreeElement.py", "src/github/Hook.py", "src/github/Issue.py", "src/github/IssueComment.py", "src/github/IssueEvent.py", "src/github/Label.py", "src/github/Milestone.py", "src/github/NamedUser.py", "src/github/Organization.py", "src/github/Permissions.py", "src/github/Plan.py", "src/github/PullRequest.py", "src/github/PullRequestComment.py", "src/github/PullRequestFile.py", "src/github/Repository.py", "src/github/RepositoryKey.py", "src/github/Tag.py", "src/github/Team.py", "src/github/UserKey.py", "test/Issue.py", "test/IssueEvent.py", "test/ReplayData/Issue.testAddAndRemoveLabels.txt", "test/ReplayData/Issue.testDeleteAndSetLabels.txt", "test/ReplayData/Issue.testGetLabels.txt", "test/ReplayData/IssueEvent.setUp.txt"]) + def testGetLabels(self): + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"]) + + def testAddAndRemoveLabels(self): + wip = self.repo.get_label("wip") + refactoring = self.repo.get_label("refactoring") + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring", "improvement"]) + self.pull.remove_from_labels(wip) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["refactoring", "improvement"]) + self.pull.remove_from_labels(refactoring) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["improvement"]) + self.pull.add_to_labels(wip, refactoring) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring", "improvement"]) + + def testAddAndRemoveLabelsWithStringArguments(self): + wip = "wip" + refactoring = "refactoring" + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring", "improvement"]) + self.pull.remove_from_labels(wip) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["refactoring", "improvement"]) + self.pull.remove_from_labels(refactoring) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["improvement"]) + self.pull.add_to_labels(wip, refactoring) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring", "improvement"]) + + def testDeleteAndSetLabels(self): + wip = self.repo.get_label("wip") + refactoring = self.repo.get_label("refactoring") + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring", "improvement"]) + self.pull.delete_labels() + self.assertListKeyEqual(self.pull.get_labels(), None, []) + self.pull.set_labels(wip, refactoring) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"]) + + def testDeleteAndSetLabelsWithStringArguments(self): + wip = "wip" + refactoring = "refactoring" + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring", "improvement"]) + self.pull.delete_labels() + self.assertListKeyEqual(self.pull.get_labels(), None, []) + self.pull.set_labels(wip, refactoring) + self.assertListKeyEqual(self.pull.get_labels(), lambda l: l.name, ["wip", "refactoring"]) + def testMerge(self): self.assertFalse(self.pull.is_merged()) status = self.pull.merge() diff --git a/github/tests/ReplayData/PullRequest.setUp.txt b/github/tests/ReplayData/PullRequest.setUp.txt index 0c0581af..c387ee14 100644 --- a/github/tests/ReplayData/PullRequest.setUp.txt +++ b/github/tests/ReplayData/PullRequest.setUp.txt @@ -29,5 +29,5 @@ None None 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},"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"} +{"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","labels":[{"id":264033039,"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"eb6420","default":false}]} diff --git a/github/tests/ReplayData/PullRequest.testAddAndRemoveLabels.txt b/github/tests/ReplayData/PullRequest.testAddAndRemoveLabels.txt new file mode 100644 index 00000000..6e33613b --- /dev/null +++ b/github/tests/ReplayData/PullRequest.testAddAndRemoveLabels.txt @@ -0,0 +1,99 @@ +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/labels/wip +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('content-length', '97'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"569c414d87e8ec43ec269a9e28bc2982"'), ('date', 'Sun, 27 May 2012 09:04:01 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"color":"eb6420","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip"} + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/labels/refactoring +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('content-length', '113'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"b659c8dcc1212c71f826547c3cc7ae99"'), ('date', 'Sun, 27 May 2012 09:04:02 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"} + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('content-length', '328'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 09:04:03 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +DELETE +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels/wip +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '229'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"46cc70bad88a09b559a5e67089005105"'), ('date', 'Sun, 27 May 2012 09:04:03 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '229'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"46cc70bad88a09b559a5e67089005105"'), ('date', 'Sun, 27 May 2012 09:04:04 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +DELETE +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels/refactoring +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '115'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5352ae15c8a5a36c6cace63be9367332"'), ('date', 'Sun, 27 May 2012 09:04:04 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('content-length', '115'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5352ae15c8a5a36c6cace63be9367332"'), ('date', 'Sun, 27 May 2012 09:04:05 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +POST +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +["wip", "refactoring"] +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '328'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d135d74d2ea2159d044676a220d41d3a"'), ('date', 'Sun, 27 May 2012 09:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4984'), ('content-length', '328'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 09:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + diff --git a/github/tests/ReplayData/PullRequest.testAddAndRemoveLabelsWithStringArguments.txt b/github/tests/ReplayData/PullRequest.testAddAndRemoveLabelsWithStringArguments.txt new file mode 100644 index 00000000..6f5b7d8c --- /dev/null +++ b/github/tests/ReplayData/PullRequest.testAddAndRemoveLabelsWithStringArguments.txt @@ -0,0 +1,77 @@ +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('content-length', '328'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 09:04:03 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +DELETE +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels/wip +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '229'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"46cc70bad88a09b559a5e67089005105"'), ('date', 'Sun, 27 May 2012 09:04:03 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '229'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"46cc70bad88a09b559a5e67089005105"'), ('date', 'Sun, 27 May 2012 09:04:04 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +DELETE +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels/refactoring +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '115'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5352ae15c8a5a36c6cace63be9367332"'), ('date', 'Sun, 27 May 2012 09:04:04 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('content-length', '115'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5352ae15c8a5a36c6cace63be9367332"'), ('date', 'Sun, 27 May 2012 09:04:05 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +POST +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +["wip", "refactoring"] +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '328'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d135d74d2ea2159d044676a220d41d3a"'), ('date', 'Sun, 27 May 2012 09:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4984'), ('content-length', '328'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 09:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + diff --git a/github/tests/ReplayData/PullRequest.testDeleteAndSetLabels.txt b/github/tests/ReplayData/PullRequest.testDeleteAndSetLabels.txt new file mode 100644 index 00000000..18136654 --- /dev/null +++ b/github/tests/ReplayData/PullRequest.testDeleteAndSetLabels.txt @@ -0,0 +1,77 @@ +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/labels/wip +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('content-length', '97'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"569c414d87e8ec43ec269a9e28bc2982"'), ('date', 'Sun, 27 May 2012 09:04:01 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"color":"eb6420","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip"} + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/labels/refactoring +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('content-length', '113'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"b659c8dcc1212c71f826547c3cc7ae99"'), ('date', 'Sun, 27 May 2012 09:04:02 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"} + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4972'), ('content-length', '335'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d135d74d2ea2159d044676a220d41d3a"'), ('date', 'Sun, 27 May 2012 09:06:39 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +DELETE +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +204 +[('status', '204 No Content'), ('x-ratelimit-remaining', '4971'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 27 May 2012 09:06:39 GMT')] + + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4970'), ('content-length', '2'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d751713988987e9331980363e24189ce"'), ('date', 'Sun, 27 May 2012 09:06:40 GMT'), ('content-type', 'application/json; charset=utf-8')] +[] + +https +PUT +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +["wip", "refactoring"] +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4969'), ('content-length', '213'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1a56634d9c1050a88592ff55ed8adc62"'), ('date', 'Sun, 27 May 2012 09:06:40 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4968'), ('content-length', '213'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1a56634d9c1050a88592ff55ed8adc62"'), ('date', 'Sun, 27 May 2012 09:06:41 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"}] + diff --git a/github/tests/ReplayData/PullRequest.testDeleteAndSetLabelsWithStringArguments.txt b/github/tests/ReplayData/PullRequest.testDeleteAndSetLabelsWithStringArguments.txt new file mode 100644 index 00000000..934f4102 --- /dev/null +++ b/github/tests/ReplayData/PullRequest.testDeleteAndSetLabelsWithStringArguments.txt @@ -0,0 +1,55 @@ +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4972'), ('content-length', '335'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d135d74d2ea2159d044676a220d41d3a"'), ('date', 'Sun, 27 May 2012 09:06:39 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/improvement","name":"improvement","color":"ffffff"}] + +https +DELETE +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +204 +[('status', '204 No Content'), ('x-ratelimit-remaining', '4971'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 27 May 2012 09:06:39 GMT')] + + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4970'), ('content-length', '2'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d751713988987e9331980363e24189ce"'), ('date', 'Sun, 27 May 2012 09:06:40 GMT'), ('content-type', 'application/json; charset=utf-8')] +[] + +https +PUT +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +["wip", "refactoring"] +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4969'), ('content-length', '213'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1a56634d9c1050a88592ff55ed8adc62"'), ('date', 'Sun, 27 May 2012 09:06:40 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"}] + +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4968'), ('content-length', '213'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1a56634d9c1050a88592ff55ed8adc62"'), ('date', 'Sun, 27 May 2012 09:06:41 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"}] + diff --git a/github/tests/ReplayData/PullRequest.testGetLabels.txt b/github/tests/ReplayData/PullRequest.testGetLabels.txt new file mode 100644 index 00000000..6c28cec1 --- /dev/null +++ b/github/tests/ReplayData/PullRequest.testGetLabels.txt @@ -0,0 +1,11 @@ +https +GET +api.github.com +None +/repos/jacquev6/PyGithub/pulls/31/labels +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('content-length', '214'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 08:56:31 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/wip","name":"wip","color":"eb6420"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/refactoring","name":"refactoring","color":"fbca04"}] +