From 737f0c3ebe53f02bd2e7c31cd4c24cf59034c02a Mon Sep 17 00:00:00 2001 From: Kyle Hornberg Date: Thu, 31 Dec 2015 09:07:58 -0600 Subject: [PATCH] Add branch protection endpoint --- github/Branch.py | 25 +++++ github/Repository.py | 46 +++++++++ github/tests/Branch.py | 7 ++ .../Branch.testProtectedAttributes.txt | 33 +++++++ ...ory.testChangeBranchProtectionContexts.txt | 66 +++++++++++++ ...ChangeBranchProtectionEnforcementLevel.txt | 44 +++++++++ .../Repository.testProtectBranch.txt | 22 +++++ ...hProtectionWithInvalidEnforcementLevel.txt | 11 +++ ...rrorWithBranchProtectionWithOutContext.txt | 11 +++ ...Repository.testRaiseErrorWithOutBranch.txt | 11 +++ .../Repository.testRemoveBranchProtection.txt | 22 +++++ github/tests/Repository.py | 98 ++++++++++++++++++- 12 files changed, 394 insertions(+), 2 deletions(-) create mode 100644 github/tests/ReplayData/Branch.testProtectedAttributes.txt create mode 100644 github/tests/ReplayData/Repository.testChangeBranchProtectionContexts.txt create mode 100644 github/tests/ReplayData/Repository.testChangeBranchProtectionEnforcementLevel.txt create mode 100644 github/tests/ReplayData/Repository.testProtectBranch.txt create mode 100644 github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithInvalidEnforcementLevel.txt create mode 100644 github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithOutContext.txt create mode 100644 github/tests/ReplayData/Repository.testRaiseErrorWithOutBranch.txt create mode 100644 github/tests/ReplayData/Repository.testRemoveBranchProtection.txt diff --git a/github/Branch.py b/github/Branch.py index 88ffb7b3..c2acc0f3 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -49,6 +49,27 @@ class Branch(github.GithubObject.NonCompletableGithubObject): """ return self._name.value + @property + def protected(self): + """ + :type: bool + """ + return self._protected.value + + @property + def enforcement_level(self): + """ + :type: string + """ + return self._enforcement_level.value + + @property + def contexts(self): + """ + :type: list of strings + """ + return self._contexts.value + def _initAttributes(self): self._commit = github.GithubObject.NotSet self._name = github.GithubObject.NotSet @@ -58,3 +79,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject): self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) + if "protection" in attributes: + self._protected = self._makeBoolAttribute(attributes["protection"]["enabled"]) + self._enforcement_level = self._makeStringAttribute(attributes["protection"]["required_status_checks"]["enforcement_level"]) + self._contexts = self._makeListOfStringsAttribute(attributes["protection"]["required_status_checks"]["contexts"]) diff --git a/github/Repository.py b/github/Repository.py index 64c96e3e..38035480 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -1090,6 +1090,20 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return github.Branch.Branch(self._requester, headers, data, completed=True) + def get_protected_branch(self, branch): + """ + :calls: `GET /repos/:owner/:repo/branches/:branch `_ + :param branch: string + :rtype: :class:`github.Branch.Branch` + """ + assert isinstance(branch, (str, unicode)), branch + headers, data = self._requester.requestJsonAndCheck( + "GET", + self.url + "/branches/" + branch, + headers={'Accept': 'application/vnd.github.loki-preview+json'} + ) + return github.Branch.Branch(self._requester, headers, data, completed=True) + def get_branches(self): """ :calls: `GET /repos/:owner/:repo/branches `_ @@ -2007,6 +2021,38 @@ class Repository(github.GithubObject.CompletableGithubObject): else: return github.Commit.Commit(self._requester, headers, data, completed=True) + def protect_branch(self, branch, enabled, enforcement_level=github.GithubObject.NotSet, contexts=github.GithubObject.NotSet): + """ + :calls: `PATCH /repos/:owner/:repo/branches/:branch `_ + :param branch: string + :param enabled: boolean + :param enforcement_level: string + :param contexts: list of strings + :rtype: None + """ + + assert isinstance(branch, (str, unicode)) + assert isinstance(enabled, bool) + assert enforcement_level is github.GithubObject.NotSet or isinstance(enforcement_level, (str, unicode)), enforcement_level + assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, str) for element in contexts), contexts + + post_parameters = { + "protection": {} + } + if enabled is not github.GithubObject.NotSet: + post_parameters["protection"]["enabled"] = enabled + if enforcement_level is not github.GithubObject.NotSet: + post_parameters["protection"]["required_status_checks"] = {} + post_parameters["protection"]["required_status_checks"]["enforcement_level"] = enforcement_level + if contexts is not github.GithubObject.NotSet: + post_parameters["protection"]["required_status_checks"]["contexts"] = contexts + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url + "/branches/" + branch, + input=post_parameters, + headers={'Accept': 'application/vnd.github.loki-preview+json'} + ) + def remove_from_collaborators(self, collaborator): """ :calls: `DELETE /repos/:owner/:repo/collaborators/:user `_ diff --git a/github/tests/Branch.py b/github/tests/Branch.py index 38b39029..b2944264 100644 --- a/github/tests/Branch.py +++ b/github/tests/Branch.py @@ -34,3 +34,10 @@ class Branch(Framework.TestCase): def testAttributes(self): self.assertEqual(self.branch.name, "topic/RewriteWithGeneratedCode") self.assertEqual(self.branch.commit.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a") + + def testProtectedAttributes(self): + self.branch = self.g.get_user().get_repo("PyGithub").get_protected_branch("master") + self.assertEqual(self.branch.name, "master") + self.assertFalse(self.branch.protected) + self.assertEqual(self.branch.enforcement_level, "off") + self.assertEqual(self.branch.contexts, []) diff --git a/github/tests/ReplayData/Branch.testProtectedAttributes.txt b/github/tests/ReplayData/Branch.testProtectedAttributes.txt new file mode 100644 index 00000000..89f1c6b3 --- /dev/null +++ b/github/tests/ReplayData/Branch.testProtectedAttributes.txt @@ -0,0 +1,33 @@ +https +GET +api.github.com +None +/user +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '1330'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'e724c57ebb9961c772a91e2dd7421c8d'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"1b171bef9da5a5bcca9799131499edae"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4925'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'AE1E5031:14B57:766BC21:568E7104'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('last-modified', 'Wed, 06 Jan 2016 19:09:00 GMT'), ('date', 'Thu, 07 Jan 2016 14:07:00 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452177625')] +{"login":"khornberg","id":3442051,"avatar_url":"https://avatars.githubusercontent.com/u/3442051?v=3","gravatar_id":"","url":"https://api.github.com/users/khornberg","html_url":"https://github.com/khornberg","followers_url":"https://api.github.com/users/khornberg/followers","following_url":"https://api.github.com/users/khornberg/following{/other_user}","gists_url":"https://api.github.com/users/khornberg/gists{/gist_id}","starred_url":"https://api.github.com/users/khornberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khornberg/subscriptions","organizations_url":"https://api.github.com/users/khornberg/orgs","repos_url":"https://api.github.com/users/khornberg/repos","events_url":"https://api.github.com/users/khornberg/events{/privacy}","received_events_url":"https://api.github.com/users/khornberg/received_events","type":"User","site_admin":false,"name":"Kyle Hornberg","company":null,"blog":"https://khornberg.github.io","location":null,"email":null,"hireable":null,"bio":null,"public_repos":40,"public_gists":9,"followers":7,"following":2,"created_at":"2013-01-31T20:22:05Z","updated_at":"2016-01-06T19:09:00Z","private_gists":1,"total_private_repos":0,"owned_private_repos":0,"disk_usage":16433,"collaborators":0,"plan":{"name":"free","space":976562499,"collaborators":0,"private_repos":0}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '13870'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'a30e6f9aa7cf5731b87dfb3b9992202d'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"c874b56da60decc8687ee4ed43dcd3aa"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4924'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'AE1E5031:14B61:23FC1AEB:568E7104'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('last-modified', 'Thu, 31 Dec 2015 15:01:40 GMT'), ('date', 'Thu, 07 Jan 2016 14:07:01 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452177625')] +{"id":48852849,"name":"PyGithub","full_name":"khornberg/PyGithub","owner":{"login":"khornberg","id":3442051,"avatar_url":"https://avatars.githubusercontent.com/u/3442051?v=3","gravatar_id":"","url":"https://api.github.com/users/khornberg","html_url":"https://github.com/khornberg","followers_url":"https://api.github.com/users/khornberg/followers","following_url":"https://api.github.com/users/khornberg/following{/other_user}","gists_url":"https://api.github.com/users/khornberg/gists{/gist_id}","starred_url":"https://api.github.com/users/khornberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khornberg/subscriptions","organizations_url":"https://api.github.com/users/khornberg/orgs","repos_url":"https://api.github.com/users/khornberg/repos","events_url":"https://api.github.com/users/khornberg/events{/privacy}","received_events_url":"https://api.github.com/users/khornberg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khornberg/PyGithub","description":"Python library implementing the GitHub API v3","fork":true,"url":"https://api.github.com/repos/khornberg/PyGithub","forks_url":"https://api.github.com/repos/khornberg/PyGithub/forks","keys_url":"https://api.github.com/repos/khornberg/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khornberg/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khornberg/PyGithub/teams","hooks_url":"https://api.github.com/repos/khornberg/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/khornberg/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/khornberg/PyGithub/events","assignees_url":"https://api.github.com/repos/khornberg/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/khornberg/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/khornberg/PyGithub/tags","blobs_url":"https://api.github.com/repos/khornberg/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khornberg/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khornberg/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/khornberg/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khornberg/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/khornberg/PyGithub/languages","stargazers_url":"https://api.github.com/repos/khornberg/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/khornberg/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/khornberg/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/khornberg/PyGithub/subscription","commits_url":"https://api.github.com/repos/khornberg/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/khornberg/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/khornberg/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/khornberg/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/khornberg/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/khornberg/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khornberg/PyGithub/merges","archive_url":"https://api.github.com/repos/khornberg/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khornberg/PyGithub/downloads","issues_url":"https://api.github.com/repos/khornberg/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/khornberg/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/khornberg/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/khornberg/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khornberg/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/khornberg/PyGithub/releases{/id}","created_at":"2015-12-31T15:01:38Z","updated_at":"2015-12-31T15:01:40Z","pushed_at":"2015-12-31T15:07:58Z","git_url":"git://github.com/khornberg/PyGithub.git","ssh_url":"git@github.com:khornberg/PyGithub.git","clone_url":"https://github.com/khornberg/PyGithub.git","svn_url":"https://github.com/khornberg/PyGithub","homepage":"http://jacquev6.github.io/PyGithub","size":12973,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"parent":{"id":3544490,"name":"PyGithub","full_name":"PyGithub/PyGithub","owner":{"login":"PyGithub","id":11288996,"avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=3","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PyGithub/PyGithub","description":"Python library implementing the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","created_at":"2012-02-25T12:53:47Z","updated_at":"2016-01-07T11:45:22Z","pushed_at":"2016-01-04T13:48:35Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"http://jacquev6.github.io/PyGithub","size":13065,"stargazers_count":740,"watchers_count":740,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":231,"mirror_url":null,"open_issues_count":43,"forks":231,"open_issues":43,"watchers":740,"default_branch":"master"},"source":{"id":3544490,"name":"PyGithub","full_name":"PyGithub/PyGithub","owner":{"login":"PyGithub","id":11288996,"avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=3","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PyGithub/PyGithub","description":"Python library implementing the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","created_at":"2012-02-25T12:53:47Z","updated_at":"2016-01-07T11:45:22Z","pushed_at":"2016-01-04T13:48:35Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"http://jacquev6.github.io/PyGithub","size":13065,"stargazers_count":740,"watchers_count":740,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":231,"mirror_url":null,"open_issues_count":43,"forks":231,"open_issues":43,"watchers":740,"default_branch":"master"},"network_count":231,"subscribers_count":1} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3589'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'b0ef53392caa42315c6206737946d931'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"62bfcfb47e26986d4c1a6db0bcf43cb6"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4923'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'AE1E5031:14B59:AE47571:568E7105'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Thu, 07 Jan 2016 14:07:01 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452177625')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":false,"required_status_checks":{"enforcement_level":"off","contexts":[]}}} + diff --git a/github/tests/ReplayData/Repository.testChangeBranchProtectionContexts.txt b/github/tests/ReplayData/Repository.testChangeBranchProtectionContexts.txt new file mode 100644 index 00000000..36efd194 --- /dev/null +++ b/github/tests/ReplayData/Repository.testChangeBranchProtectionContexts.txt @@ -0,0 +1,66 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone", "contexts": ["test"]}}} +200 +[('content-length', '3599'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '76d9828c7e4f1d910f7ba069e90ce976'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"23247e636875225f1e2d6b49e3ed8fb5"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4983'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D25A:7429E1A:568D31F4'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:25:40 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["test"]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3599'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'bae57931a6fe678a3dffe9be8e7819c8'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"23247e636875225f1e2d6b49e3ed8fb5"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4982'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D262:27FA573A:568D31F4'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:25:40 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["test"]}}} + +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone", "contexts": ["test", "default"]}}} +200 +[('content-length', '3609'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '318e55760cf7cdb40e61175a4d36cd32'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"db7b04fd5e1b51731388d165caa9c4aa"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4981'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D262:27FA5773:568D31F4'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:25:41 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["default","test"]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3609'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'a241e1a8264a6ace03db946c85b92db3'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"db7b04fd5e1b51731388d165caa9c4aa"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4980'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D260:22667B15:568D31F5'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:25:41 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["default","test"]}}} + +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone", "contexts": ["default"]}}} +200 +[('content-length', '3602'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '593010132f82159af0ded24b4932e109'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"9ec429649fdda2858153edc42ff3f579"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4979'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D25F:1A8AB79A:568D31F5'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:25:41 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["default"]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3602'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'ef96c2e493b28ffea49b891b085ed2dd'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"9ec429649fdda2858153edc42ff3f579"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4978'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D262:27FA5800:568D31F5'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:25:41 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["default"]}}} + diff --git a/github/tests/ReplayData/Repository.testChangeBranchProtectionEnforcementLevel.txt b/github/tests/ReplayData/Repository.testChangeBranchProtectionEnforcementLevel.txt new file mode 100644 index 00000000..8192af2f --- /dev/null +++ b/github/tests/ReplayData/Repository.testChangeBranchProtectionEnforcementLevel.txt @@ -0,0 +1,44 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone", "contexts": ["test"]}}} +200 +[('content-length', '3599'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'dc1ce2bfb41810a06c705e83b388572d'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"23247e636875225f1e2d6b49e3ed8fb5"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4950'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D25F:1A90BAC8:568D38A5'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:54:13 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["test"]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3599'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '2c18a09f3ac5e4dd1e004af7c5a94769'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"23247e636875225f1e2d6b49e3ed8fb5"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4949'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D261:29009CF7:568D38A5'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:54:13 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["test"]}}} + +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "non_admins", "contexts": ["test"]}}} +200 +[('content-length', '3601'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '52437fedc85beec8da3449496900fb9a'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"33854f0fd77af9f49acf152bf0715de3"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4948'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D25F:1A90BB33:568D38A5'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:54:14 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"non_admins","contexts":["test"]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3601'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '13d09b732ebe76f892093130dc088652'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"33854f0fd77af9f49acf152bf0715de3"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4947'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:1D260:226E126E:568D38A7'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:54:15 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"non_admins","contexts":["test"]}}} + diff --git a/github/tests/ReplayData/Repository.testProtectBranch.txt b/github/tests/ReplayData/Repository.testProtectBranch.txt new file mode 100644 index 00000000..6237ff02 --- /dev/null +++ b/github/tests/ReplayData/Repository.testProtectBranch.txt @@ -0,0 +1,22 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone", "contexts": ["test"]}}} +200 +[('content-length', '3599'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '13d09b732ebe76f892093130dc088652'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"23247e636875225f1e2d6b49e3ed8fb5"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:14B62:29334564:568D2D11'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:04:49 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["test"]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3599'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'a474937f3b2fa272558fa6dc951018ad'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"23247e636875225f1e2d6b49e3ed8fb5"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:14B62:293345B4:568D2D11'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:04:49 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":true,"required_status_checks":{"enforcement_level":"everyone","contexts":["test"]}}} + diff --git a/github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithInvalidEnforcementLevel.txt b/github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithInvalidEnforcementLevel.txt new file mode 100644 index 00000000..26522f95 --- /dev/null +++ b/github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithInvalidEnforcementLevel.txt @@ -0,0 +1,11 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "", "contexts": ["test"]}}} +422 +[('status', '422 Unprocessable Entity'), ('content-length', '331'), ('x-github-media-type', 'github.loki-preview; format=json'), ('x-content-type-options', 'nosniff'), ('content-security-policy', "default-src 'none'"), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'AE1E5031:134EF:B336C18:568E6F16'), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('x-ratelimit-remaining', '4958'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-xss-protection', '1; mode=block'), ('access-control-allow-credentials', 'true'), ('date', 'Thu, 07 Jan 2016 13:58:47 GMT'), ('access-control-allow-origin', '*'), ('content-type', 'application/json; charset=utf-8'), ('x-frame-options', 'deny'), ('x-ratelimit-reset', '1452177625')] +{"message":"Validation Failed","errors":[{"resource":"ProtectedBranch","code":"custom","field":"required_status_checks_enforcement_level","message":"required_status_checks_enforcement_level enforcement level '%s' is not valid"}],"documentation_url":"https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection"} + diff --git a/github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithOutContext.txt b/github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithOutContext.txt new file mode 100644 index 00000000..9ec138ec --- /dev/null +++ b/github/tests/ReplayData/Repository.testRaiseErrorWithBranchProtectionWithOutContext.txt @@ -0,0 +1,11 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone"}}} +422 +[('status', '422 Unprocessable Entity'), ('content-length', '117'), ('x-github-media-type', 'github.loki-preview; format=json'), ('x-content-type-options', 'nosniff'), ('content-security-policy', "default-src 'none'"), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'AE1E5031:1D259:685F04B:568E6DC2'), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('x-ratelimit-remaining', '4969'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-xss-protection', '1; mode=block'), ('access-control-allow-credentials', 'true'), ('date', 'Thu, 07 Jan 2016 13:53:06 GMT'), ('access-control-allow-origin', '*'), ('content-type', 'application/json; charset=utf-8'), ('x-frame-options', 'deny'), ('x-ratelimit-reset', '1452177625')] +{"message":"Invalid request.\n\n\"contexts\" wasn't supplied.","documentation_url":"https://developer.github.com/v3"} + diff --git a/github/tests/ReplayData/Repository.testRaiseErrorWithOutBranch.txt b/github/tests/ReplayData/Repository.testRaiseErrorWithOutBranch.txt new file mode 100644 index 00000000..a72bb382 --- /dev/null +++ b/github/tests/ReplayData/Repository.testRaiseErrorWithOutBranch.txt @@ -0,0 +1,11 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/ +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": true, "required_status_checks": {"enforcement_level": "everyone", "contexts": ["test"]}}} +404 +[('status', '404 Not Found'), ('content-length', '102'), ('x-github-media-type', 'github.loki-preview; format=json'), ('x-content-type-options', 'nosniff'), ('content-security-policy', "default-src 'none'"), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'AE1E5031:A39B:2D392574:568E6BC1'), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('x-ratelimit-remaining', '4991'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-xss-protection', '1; mode=block'), ('access-control-allow-credentials', 'true'), ('date', 'Thu, 07 Jan 2016 13:44:34 GMT'), ('access-control-allow-origin', '*'), ('content-type', 'application/json; charset=utf-8'), ('x-frame-options', 'deny'), ('x-ratelimit-reset', '1452177625')] +{"message":"Branch not found","documentation_url":"https://developer.github.com/v3/repos/#get-branch"} + diff --git a/github/tests/ReplayData/Repository.testRemoveBranchProtection.txt b/github/tests/ReplayData/Repository.testRemoveBranchProtection.txt new file mode 100644 index 00000000..07ba499d --- /dev/null +++ b/github/tests/ReplayData/Repository.testRemoveBranchProtection.txt @@ -0,0 +1,22 @@ +https +PATCH +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +{"protection": {"enabled": false}} +200 +[('content-length', '3589'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'a7f8a126c9ed3f1c4715a34c0ddc7290'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"62bfcfb47e26986d4c1a6db0bcf43cb6"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4993'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:14B5A:E23F8D0:568D3163'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:23:15 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":false,"required_status_checks":{"enforcement_level":"off","contexts":[]}}} + +https +GET +api.github.com +None +/repos/khornberg/PyGithub/branches/master +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.loki-preview+json', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '3589'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'c6c65e5196703428e7641f7d1e9bc353'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('etag', '"62bfcfb47e26986d4c1a6db0bcf43cb6"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('x-github-media-type', 'github.loki-preview; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '417D879D:14B61:22B7F0CB:568D3164'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 06 Jan 2016 15:23:16 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1452096288')] +{"name":"master","commit":{"sha":"a39c1e8b9ab601419277eefb4fbb586ded0af146","commit":{"author":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"committer":{"name":"Jimmy Zelinskie","email":"jimmyzelinskie@gmail.com","date":"2015-12-16T06:29:19Z"},"message":"Merge pull request #365 from PyGithub/nhomar-travis-button\n\nAdd travis button on README.","tree":{"sha":"33b533e02e45deccc832bc39813710764fb2a9d4","url":"https://api.github.com/repos/khornberg/PyGithub/git/trees/33b533e02e45deccc832bc39813710764fb2a9d4"},"url":"https://api.github.com/repos/khornberg/PyGithub/git/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","comment_count":0},"url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146","html_url":"https://github.com/khornberg/PyGithub/commit/a39c1e8b9ab601419277eefb4fbb586ded0af146","comments_url":"https://api.github.com/repos/khornberg/PyGithub/commits/a39c1e8b9ab601419277eefb4fbb586ded0af146/comments","author":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"committer":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars.githubusercontent.com/u/343539?v=3","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"parents":[{"sha":"45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","url":"https://api.github.com/repos/khornberg/PyGithub/commits/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5","html_url":"https://github.com/khornberg/PyGithub/commit/45c7f072e4732f89a9e756a27a4306f2f6dbd9c5"},{"sha":"a83649b68f1bb978c254f4cf1efcae88dc2608d7","url":"https://api.github.com/repos/khornberg/PyGithub/commits/a83649b68f1bb978c254f4cf1efcae88dc2608d7","html_url":"https://github.com/khornberg/PyGithub/commit/a83649b68f1bb978c254f4cf1efcae88dc2608d7"}]},"_links":{"self":"https://api.github.com/repos/khornberg/PyGithub/branches/master","html":"https://github.com/khornberg/PyGithub/tree/master"},"protection":{"enabled":false,"required_status_checks":{"enforcement_level":"off","contexts":[]}}} + diff --git a/github/tests/Repository.py b/github/tests/Repository.py index a2d9bb76..7e142a2d 100644 --- a/github/tests/Repository.py +++ b/github/tests/Repository.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # ########################## Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # @@ -69,6 +67,102 @@ class Repository(Framework.TestCase): self.assertEqual(self.repo.url, "https://api.github.com/repos/jacquev6/PyGithub") self.assertEqual(self.repo.watchers, 15) + def testProtectBranch(self): + self.repo.protect_branch("master", True, "everyone", ["test"]) + branch = self.repo.get_protected_branch("master") + self.assertTrue(branch.protected) + self.assertEqual(branch.enforcement_level, "everyone") + self.assertEqual(branch.contexts, ["test"]) + # Remove Protection + self.repo.protect_branch("master", False) + + def testRemoveBranchProtection(self): + self.repo.protect_branch("master", False) + branch = self.repo.get_protected_branch("master") + self.assertFalse(branch.protected) + self.assertEqual(branch.enforcement_level, "off") + self.assertEqual(branch.contexts, []) + + def testChangeBranchProtectionContexts(self): + self.repo.protect_branch("master", True, "everyone", ["test"]) + branch = self.repo.get_protected_branch("master") + self.assertTrue(branch.protected) + self.assertEqual(branch.enforcement_level, "everyone") + self.assertEqual(branch.contexts, ["test"]) + self.repo.protect_branch("master", True, "everyone", ["test", "default"]) + branch = self.repo.get_protected_branch("master") + self.assertEqual(branch.contexts, ["default", "test"]) + self.repo.protect_branch("master", True, "everyone", ["default"]) + branch = self.repo.get_protected_branch("master") + self.assertEqual(branch.contexts, ["default"]) + # Remove Protection + self.repo.protect_branch("master", False) + + def testRaiseErrorWithOutBranch(self): + raised = False + try: + self.repo.protect_branch("", True, "everyone", ["test"]) + except github.GithubException, exception: + raised = True + self.assertEqual(exception.status, 404) + self.assertEqual( + exception.data, { + u'documentation_url': u'https://developer.github.com/v3/repos/#get-branch', + u'message': u'Branch not found' + } + ) + self.assertTrue(raised) + + def testRaiseErrorWithBranchProtectionWithOutContext(self): + raised = False + try: + self.repo.protect_branch("master", True, "everyone") + except github.GithubException, exception: + raised = True + self.assertEqual(exception.status, 422) + self.assertEqual( + exception.data, { + u'documentation_url': u'https://developer.github.com/v3', + u'message': u'Invalid request.\n\n"contexts" wasn\'t supplied.' + } + ) + self.assertTrue(raised) + + def testRaiseErrorWithBranchProtectionWithInvalidEnforcementLevel(self): + raised = False + try: + self.repo.protect_branch("master", True, "", ["test"]) + except github.GithubException, exception: + raised = True + self.assertEqual(exception.status, 422) + self.assertEqual( + exception.data, { + u'documentation_url': + u'https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection', + u'message': u'Validation Failed', + u'errors': [ + { + u'field': u'required_status_checks_enforcement_level', + u'message': u"required_status_checks_enforcement_level enforcement level '%s' is not valid", + u'code': u'custom', + u'resource': u'ProtectedBranch' + } + ] + } + ) + self.assertTrue(raised) + + def testChangeBranchProtectionEnforcementLevel(self): + self.repo.protect_branch("master", True, "everyone", ["test"]) + branch = self.repo.get_protected_branch("master") + self.assertTrue(branch.protected) + self.assertEqual(branch.enforcement_level, "everyone") + self.repo.protect_branch("master", True, "non_admins", ["test"]) + branch = self.repo.get_protected_branch("master") + self.assertEqual(branch.enforcement_level, "non_admins") + # Remove Protection + self.repo.protect_branch("master", False) + def testEditWithoutArguments(self): self.repo.edit("PyGithub")