Repository: Sage-Bionetworks/challengeutils

Issue:
removal of members from a Team

Discussion:
pep8speaks: Hello @thomasyu888! Thanks for opening this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:



* In the file [`tests/test_utils.py`](https://github.com/Sage-Bionetworks/challengeutils/blob/58954c066ba8a7254b585388dbb656d10f3e9d20/tests/test_utils.py):

> [Line 281:9](https://github.com/Sage-Bionetworks/challengeutils/blob/58954c066ba8a7254b585388dbb656d10f3e9d20/tests/test_utils.py#L281): [E221](https://duckduckgo.com/?q=pep8%20E221) multiple spaces before operator



Patch:
diff --git a/challengeutils/utils.py b/challengeutils/utils.py
index 984eae1..33e3d6c 100644
--- a/challengeutils/utils.py
+++ b/challengeutils/utils.py
@@ -11,6 +11,7 @@ import synapseclient
 from synapseclient.annotations import (is_submission_status_annotations,
                                        to_submission_status_annotations)
 from synapseclient.core.exceptions import SynapseHTTPError
+from synapseclient.core.utils import id_of
 
 logging.basicConfig(level=logging.INFO)
 logger = logging.getLogger(__name__)
@@ -517,3 +518,16 @@ def delete_submission(syn, submissionid):
     """
     sub = syn.getSubmission(submissionid, downloadFile=False)
     syn.delete(sub)
+
+
+def remove_team_member(syn, team, user):
+    """Removes team member
+
+    Args:
+        syn: Synapse object
+        team: synaspeclient.Team or its id
+        user: synapseclient.UserProfile or its id
+    """
+    teamid = id_of(team)
+    userid = id_of(user)
+    syn.restDELETE(f"/team/{teamid}/member/{userid}")


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 5979fb1..339b953 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -275,3 +275,14 @@ def test_delete_submission():
         challengeutils.utils.delete_submission(syn, "12345")
         patch_get.assert_called_once_with("12345", downloadFile=False)
         patch_delete.assert_called_once_with(sub)
+
+
+def test_remove_team_member():
+    team = synapseclient.Team(id=123)
+    user = synapseclient.UserProfile(ownerId=2222)
+
+    with patch.object(syn, "restDELETE") as patch_rest:
+        challengeutils.utils.remove_team_member(syn, team, user)
+        patch_rest.assert_called_once_with(
+            "/team/123/member/2222"
+        )