forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_github.py
More file actions
55 lines (43 loc) · 1.88 KB
/
Copy pathtest_github.py
File metadata and controls
55 lines (43 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from github3.github import GitHub
from .helper import UnitHelper
class TestGitHub(UnitHelper):
described_class = GitHub
example_data = None
def test_two_factor_login(self):
self.instance.login('username', 'password',
two_factor_callback=lambda *args: 'foo')
def test_can_login_without_two_factor_callback(self):
self.instance.login('username', 'password')
self.instance.login(token='token')
class TestGitHubAuthorizations(UnitHelper):
described_class = GitHub
example_data = None
def create_session_mock(self, *args):
session = super(TestGitHubAuthorizations,
self).create_session_mock(*args)
session.retrieve_client_credentials.return_value = ('id', 'secret')
return session
def test_revoke_authorization(self):
"""Test that GitHub#revoke_authorization calls the expected methods.
It should use the session's delete and temporary_basic_auth methods.
"""
self.instance.revoke_authorization('access_token')
self.session.delete.assert_called_once_with(
'https://api.github.com/applications/id/tokens/access_token',
params={'client_id': None, 'client_secret': None}
)
self.session.temporary_basic_auth.assert_called_once_with(
'id', 'secret'
)
def test_revoke_authorizations(self):
"""Test that GitHub#revoke_authorizations calls the expected methods.
It should use the session's delete and temporary_basic_auth methods.
"""
self.instance.revoke_authorizations()
self.session.delete.assert_called_once_with(
'https://api.github.com/applications/id/tokens',
params={'client_id': None, 'client_secret': None}
)
self.session.temporary_basic_auth.assert_called_once_with(
'id', 'secret'
)