aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/tests
diff options
context:
space:
mode:
authorStefano Rivera <stefano@rivera.za.net>2012-04-24 10:42:25 +0200
committerStefano Rivera <stefano@rivera.za.net>2012-04-24 10:42:25 +0200
commit52b4a5db0be700fe6b48bfe1e0bda2bd86294db7 (patch)
tree2f914320c4f3813ec8a0058abb189fae822bb4ed /pygithub3/tests
parentAn empty string doesn't work around the 411 issue on PUTs. Use 'PLACEHOLDER' (diff)
downloadpython-github3-52b4a5db0be700fe6b48bfe1e0bda2bd86294db7.tar.xz
python-github3-52b4a5db0be700fe6b48bfe1e0bda2bd86294db7.zip
Add Teams Service
Diffstat (limited to 'pygithub3/tests')
-rw-r--r--pygithub3/tests/services/test_orgs.py83
1 files changed, 82 insertions, 1 deletions
diff --git a/pygithub3/tests/services/test_orgs.py b/pygithub3/tests/services/test_orgs.py
index e741666..4d4c1c9 100644
--- a/pygithub3/tests/services/test_orgs.py
+++ b/pygithub3/tests/services/test_orgs.py
@@ -6,7 +6,7 @@ from mock import patch, Mock
from pygithub3.tests.utils.core import TestCase
from pygithub3.resources.base import json
-from pygithub3.services.orgs import Org, Members
+from pygithub3.services.orgs import Org, Members, Teams
from pygithub3.tests.utils.base import (mock_response, mock_response_result,
mock_json)
from pygithub3.tests.utils.services import _
@@ -89,3 +89,84 @@ class TestOrgMemberService(TestCase):
self.ms.conceal_membership('acme', 'octocat')
self.assertEqual(request_method.call_args[0],
('delete', _('orgs/acme/public_members/octocat')))
+
+
+@patch.object(requests.sessions.Session, 'request')
+class TestOrgMemberService(TestCase):
+ def setUp(self):
+ self.ts = Teams()
+
+ def test_LIST(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.list('acme').all()
+ self.assertEqual(request_method.call_args[0],
+ ('get', _('orgs/acme/teams')))
+
+ def test_GET(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.get(1)
+ self.assertEqual(request_method.call_args[0], ('get', _('teams/1')))
+
+ def test_CREATE(self, request_method):
+ request_method.return_value = mock_response_result('post')
+ self.ts.create('acme', 'committers')
+ self.assertEqual(request_method.call_args[0],
+ ('post', _('orgs/acme/teams')))
+
+ def test_UPDATE(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.update(1, 'committers', 'push')
+ self.assertEqual(request_method.call_args[0], ('patch', _('teams/1')))
+
+ def test_DELETE(self, request_method):
+ request_method.return_value = mock_response_result('delete')
+ self.ts.delete(1)
+ self.assertEqual(request_method.call_args[0], ('delete', _('teams/1')))
+
+ def test_LIST_MEMBERS(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.list_members(1).all()
+ self.assertEqual(request_method.call_args[0],
+ ('get', _('teams/1/members')))
+
+ def test_IS_MEMBER(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.is_member(1, 'octocat')
+ self.assertEqual(request_method.call_args[0],
+ ('head', _('teams/1/members/octocat')))
+
+ def test_ADD_MEMBER(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.add_member(1, 'octocat')
+ self.assertEqual(request_method.call_args[0],
+ ('put', _('teams/1/members/octocat')))
+
+ def test_REMOVE_MEMBER(self, request_method):
+ request_method.return_value = mock_response_result('delete')
+ self.ts.remove_member(1, 'octocat')
+ self.assertEqual(request_method.call_args[0],
+ ('delete', _('teams/1/members/octocat')))
+
+ def test_LIST_REPOS(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.list_repos(1).all()
+ self.assertEqual(request_method.call_args[0],
+ ('get', _('teams/1/repos')))
+
+ def test_CONTAINS_REPO(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.contains_repo(1, 'octocat', 're_oct')
+ self.assertEqual(request_method.call_args[0],
+ ('head', _('teams/1/repos/octocat/re_oct')))
+
+ def test_ADD_TEAM_REPO(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.ts.add_repo(1, 'octocat', 're_oct')
+ self.assertEqual(request_method.call_args[0],
+ ('put', _('teams/1/repos/octocat/re_oct')))
+
+ def test_REMOVE_TEAM_REPO(self, request_method):
+ request_method.return_value = mock_response_result('delete')
+ self.ts.remove_repo(1, 'octocat', 're_oct')
+ self.assertEqual(request_method.call_args[0],
+ ('delete', _('teams/1/repos/octocat/re_oct')))