Add team privacy parameter to create team (#702)

* Add team privacy and add additional parameter to test. Still requires replaydata

* Reorder parameters to not break existing code

* Update tests for #702
This commit is contained in:
Raihaan
2018-04-06 17:08:34 +08:00
committed by Wan Liuyang
parent b54ccc784e
commit 5cb5ab71b3
3 changed files with 7 additions and 4 deletions
+5 -1
View File
@@ -424,17 +424,19 @@ class Organization(github.GithubObject.CompletableGithubObject):
)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def create_team(self, name, repo_names=github.GithubObject.NotSet, permission=github.GithubObject.NotSet):
def create_team(self, name, repo_names=github.GithubObject.NotSet, permission=github.GithubObject.NotSet, privacy=github.GithubObject.NotSet):
"""
:calls: `POST /orgs/:org/teams <http://developer.github.com/v3/orgs/teams>`_
:param name: string
:param repo_names: list of :class:`github.Repository.Repository`
:param permission: string
:param privacy: string
:rtype: :class:`github.Team.Team`
"""
assert isinstance(name, (str, unicode)), name
assert repo_names is github.GithubObject.NotSet or all(isinstance(element, github.Repository.Repository) for element in repo_names), repo_names
assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission
assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), privacy
post_parameters = {
"name": name,
}
@@ -442,6 +444,8 @@ class Organization(github.GithubObject.CompletableGithubObject):
post_parameters["repo_names"] = [element._identity for element in repo_names]
if permission is not github.GithubObject.NotSet:
post_parameters["permission"] = permission
if privacy is not github.GithubObject.NotSet:
post_parameters['privacy'] = privacy
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/teams",
+1 -1
View File
@@ -101,7 +101,7 @@ class Organization(Framework.TestCase):
def testCreateTeamWithAllArguments(self):
repo = self.org.get_repo("FatherBeaver")
team = self.org.create_team("Team also created by PyGithub", [repo], "push")
team = self.org.create_team("Team also created by PyGithub", [repo], "push", "secret")
self.assertEqual(team.id, 189852)
def testDeleteHook(self):
@@ -15,8 +15,7 @@ api.github.com
None
/orgs/BeaverSoftware/teams
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
{"repo_names": ["BeaverSoftware/FatherBeaver"], "name": "Team also created by PyGithub", "permission": "push"}
{"repo_names": ["BeaverSoftware/FatherBeaver"], "name": "Team also created by PyGithub", "permission": "push", "privacy": "secret"}
201
[('status', '201 Created'), ('x-ratelimit-remaining', '4982'), ('content-length', '150'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"6e3fb00de6ca4c112feee3a1438d6f0e"'), ('date', 'Sat, 26 May 2012 21:00:26 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/teams/189852')]
{"repos_count":1,"url":"https://api.github.com/teams/189852","members_count":0,"name":"Team also created by PyGithub","permission":"push","id":189852}