Repository: PyGithub/PyGithub

Issue:
Team add_membership should take parameter for role
The github api allows the use of this call to specify the role of the new member, https://developer.github.com/v3/orgs/teams/#add-or-update-team-membership. 

Team.add_membership should allow the same.
Team add_membership method needs a test

Team add_membership should take parameter for role
The github api allows the use of this call to specify the role of the new member, https://developer.github.com/v3/orgs/teams/#add-or-update-team-membership. 

Team.add_membership should allow the same.


Discussion:

Resolving patch:
diff --git a/github/Team.py b/github/Team.py
--- a/github/Team.py
+++ b/github/Team.py
@@ -125,16 +125,29 @@ def add_to_members(self, member):
             self.url + "/members/" + member._identity
         )
 
-    def add_membership(self, member):
+    def add_membership(self, member, role=github.GithubObject.NotSet):
         """
         :calls: `PUT /teams/:id/memberships/:user <http://developer.github.com/v3/orgs/teams>`_
         :param member: :class:`github.Nameduser.NamedUser`
+        :param role: string
         :rtype: None
         """
         assert isinstance(member, github.NamedUser.NamedUser), member
+        assert role is github.GithubObject.NotSet or isinstance(
+            role, (str, unicode)), role
+        if role is not github.GithubObject.NotSet:
+            assert role in ['member', 'maintainer']
+            put_parameters = {
+                "role": role,
+            }
+        else:
+            put_parameters = {
+                "role": "member",
+            }
         headers, data = self._requester.requestJsonAndCheck(
             "PUT",
-            self.url + "/memberships/" + member._identity
+            self.url + "/memberships/" + member._identity,
+            input=put_parameters
         )
 
     def add_to_repos(self, repo):


Test patch:
diff --git a/github/tests/ReplayData/Team.testMembers.txt b/github/tests/ReplayData/Team.testMembers.txt
--- a/github/tests/ReplayData/Team.testMembers.txt
+++ b/github/tests/ReplayData/Team.testMembers.txt
@@ -102,8 +102,8 @@ PUT
 api.github.com
 None
 /teams/189850/memberships/jacquev6
-{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
-None
+{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
+{"role": "maintainer"}
 200
-[('status', '200 No Content'), ('x-ratelimit-remaining', '4971'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sat, 26 May 2012 21:09:55 GMT')]
+[('status', '200 OK'), ('x-ratelimit-remaining', '4949'), ('content-length', '151'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"8856425cedbdf3075576e823f39fc3d6"'), ('date', 'Sat, 26 May 2012 21:14:46 GMT'), ('content-type', 'application/json; charset=utf-8')]
 []
diff --git a/github/tests/Team.py b/github/tests/Team.py
--- a/github/tests/Team.py
+++ b/github/tests/Team.py
@@ -54,7 +54,8 @@ def testMembers(self):
         self.team.remove_from_members(user)
         self.assertListKeyEqual(self.team.get_members(), None, [])
         self.assertFalse(self.team.has_in_members(user))
-        self.team.add_membership(user)
+        self.team.add_membership(user, "maintainer")
+        self.assertRaises(AssertionError, self.team.add_membership, user, "admin")
 
     def testRepoPermission(self):
         repo = self.org.get_repo("FatherBeaver")