66
77from pygithub3 .tests .utils .core import TestCase
88from pygithub3 .resources .base import json
9- from pygithub3 .services .orgs import Org
9+ from pygithub3 .services .orgs import Org , Members
1010from pygithub3 .tests .utils .base import (mock_response , mock_response_result ,
1111 mock_json )
1212from pygithub3 .tests .utils .services import _
1717
1818@patch .object (requests .sessions .Session , 'request' )
1919class TestOrgService (TestCase ):
20-
2120 def setUp (self ):
2221 self .org = Org ()
2322
@@ -30,7 +29,7 @@ def test_LIST_with_user(self, request_method):
3029 request_method .return_value = mock_response_result ()
3130 self .org .list ('octocat' ).all ()
3231 self .assertEqual (request_method .call_args [0 ],
33- ('get' , _ ('users/octocat/orgs' )))
32+ ('get' , _ ('users/octocat/orgs' )))
3433
3534 def test_GET (self , request_method ):
3635 request_method .return_value = mock_response ()
@@ -41,4 +40,52 @@ def test_UPDATE(self, request_method):
4140 request_method .return_value = mock_response ('patch' )
4241 self .org .update ('acme' , {'company' : 'ACME Widgets' })
4342 self .assertEqual (request_method .call_args [0 ],
44- ('patch' , _ ('orgs/acme' )))
43+ ('patch' , _ ('orgs/acme' )))
44+
45+
46+ @patch .object (requests .sessions .Session , 'request' )
47+ class TestOrgMemberService (TestCase ):
48+ def setUp (self ):
49+ self .ms = Members ()
50+
51+ def test_LIST (self , request_method ):
52+ request_method .return_value = mock_response_result ()
53+ self .ms .list ('acme' ).all ()
54+ self .assertEqual (request_method .call_args [0 ],
55+ ('get' , _ ('orgs/acme/members' )))
56+
57+ def test_IS_MEMBER (self , request_method ):
58+ request_method .return_value = mock_response ()
59+ self .ms .is_member ('acme' , 'octocat' )
60+ self .assertEqual (request_method .call_args [0 ],
61+ ('head' , _ ('orgs/acme/members/octocat' )))
62+
63+ def test_REMOVE_MEMBER (self , request_method ):
64+ request_method .return_value = mock_response ('delete' )
65+ self .ms .remove_member ('acme' , 'octocat' )
66+ self .assertEqual (request_method .call_args [0 ],
67+ ('delete' , _ ('orgs/acme/members/octocat' )))
68+
69+ def test_LIST_PUBLIC (self , request_method ):
70+ request_method .return_value = mock_response_result ()
71+ self .ms .list_public ('acme' ).all ()
72+ self .assertEqual (request_method .call_args [0 ],
73+ ('get' , _ ('orgs/acme/public_members' )))
74+
75+ def test_IS_PUBLIC_MEMBER (self , request_method ):
76+ request_method .return_value = mock_response ()
77+ self .ms .is_public_member ('acme' , 'octocat' )
78+ self .assertEqual (request_method .call_args [0 ],
79+ ('head' , _ ('orgs/acme/public_members/octocat' )))
80+
81+ def test_PUBLICIZE_MEMBERSHIP (self , request_method ):
82+ request_method .return_value = mock_response ()
83+ self .ms .publicize_membership ('acme' , 'octocat' )
84+ self .assertEqual (request_method .call_args [0 ],
85+ ('put' , _ ('orgs/acme/public_members/octocat' )))
86+
87+ def test_CONCEAL_MEMBERSHIP (self , request_method ):
88+ request_method .return_value = mock_response ('delete' )
89+ self .ms .conceal_membership ('acme' , 'octocat' )
90+ self .assertEqual (request_method .call_args [0 ],
91+ ('delete' , _ ('orgs/acme/public_members/octocat' )))
0 commit comments