From 5cb5ab71b3258f8319fdfa2c804a8cd32952e8f7 Mon Sep 17 00:00:00 2001 From: Raihaan <31362124+res0nance@users.noreply.github.com> Date: Fri, 6 Apr 2018 17:08:34 +0800 Subject: [PATCH] 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 --- github/Organization.py | 6 +++++- github/tests/Organization.py | 2 +- .../Organization.testCreateTeamWithAllArguments.txt | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/github/Organization.py b/github/Organization.py index c388d223..465dd29e 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -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 `_ :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", diff --git a/github/tests/Organization.py b/github/tests/Organization.py index 73967186..4363ef2b 100644 --- a/github/tests/Organization.py +++ b/github/tests/Organization.py @@ -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): diff --git a/github/tests/ReplayData/Organization.testCreateTeamWithAllArguments.txt b/github/tests/ReplayData/Organization.testCreateTeamWithAllArguments.txt index b44d8b90..4d3d7081 100644 --- a/github/tests/ReplayData/Organization.testCreateTeamWithAllArguments.txt +++ b/github/tests/ReplayData/Organization.testCreateTeamWithAllArguments.txt @@ -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} -