|
6 | 6 | import requests |
7 | 7 | from mock import patch, Mock |
8 | 8 |
|
9 | | -from pygithub3.services.repos import Repo |
| 9 | +from pygithub3.services.repos import Repo, Collaborator |
10 | 10 | from pygithub3.resources.base import json |
11 | 11 | from pygithub3.tests.utils.base import mock_response, mock_response_result |
12 | 12 | from pygithub3.tests.utils.services import _, mock_json |
@@ -99,7 +99,7 @@ def test_UPDATE_with_repo_in_service(self, request_method): |
99 | 99 | self.assertEqual(request_method.call_args[0], |
100 | 100 | ('patch', _('repos/octocat/octocat_repo'))) |
101 | 101 |
|
102 | | - """ From here I stop to do '*in_args' and '*filter' tests, I consider |
| 102 | + """ From here I stop to do '*in_args' and '*filter' tests, I consider |
103 | 103 | that I tested it enough... """ |
104 | 104 |
|
105 | 105 | def test_LIST_contributors(self, request_method): |
@@ -138,3 +138,35 @@ def test_LIST_branches(self, request_method): |
138 | 138 | self.rs.list_branches().all() |
139 | 139 | self.assertEqual(request_method.call_args[0], |
140 | 140 | ('get', _('repos/octocat/octocat_repo/branches'))) |
| 141 | + |
| 142 | + |
| 143 | +@patch.object(requests.sessions.Session, 'request') |
| 144 | +class TestCollaboratorsService(TestCase): |
| 145 | + |
| 146 | + def setUp(self): |
| 147 | + self.cs = Collaborator() |
| 148 | + self.cs.set_user('octocat') |
| 149 | + self.cs.set_repo('oc_repo') |
| 150 | + |
| 151 | + def test_LIST(self, request_method): |
| 152 | + request_method.return_value = mock_response_result() |
| 153 | + self.cs.list().all() |
| 154 | + self.assertEqual(request_method.call_args[0], |
| 155 | + ('get', _('repos/octocat/oc_repo/collaborators'))) |
| 156 | + |
| 157 | + def test_IS_colaborator(self, request_method): |
| 158 | + request_method.return_value = mock_response() |
| 159 | + self.cs.is_collaborator('user') |
| 160 | + self.assertEqual(request_method.call_args[0], |
| 161 | + ('head', _('repos/octocat/oc_repo/collaborators/user'))) |
| 162 | + |
| 163 | + def test_ADD(self, request_method): |
| 164 | + self.cs.add('user') |
| 165 | + self.assertEqual(request_method.call_args[0], |
| 166 | + ('put', _('repos/octocat/oc_repo/collaborators/user'))) |
| 167 | + |
| 168 | + def test_DELETE(self, request_method): |
| 169 | + request_method.return_value = mock_response('delete') |
| 170 | + self.cs.delete('user') |
| 171 | + self.assertEqual(request_method.call_args[0], |
| 172 | + ('delete', _('repos/octocat/oc_repo/collaborators/user'))) |
0 commit comments