forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_auths.py
More file actions
68 lines (52 loc) · 1.83 KB
/
test_auths.py
File metadata and controls
68 lines (52 loc) · 1.83 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
56
57
58
59
60
61
62
63
64
65
66
67
68
import github3
from tests.utils import (BaseCase, load)
class TestAuthorization(BaseCase):
def __init__(self, methodName='runTest'):
super(TestAuthorization, self).__init__(methodName)
self.auth = github3.auths.Authorization(load('authorization'))
self.api = "https://api.github.com/authorizations/10"
def setUp(self):
super(TestAuthorization, self).setUp()
self.auth = github3.auths.Authorization(self.auth.to_json(), self.g)
def test_equality(self):
a = github3.auths.Authorization(load('authorization'))
assert self.auth == a
a._uniq = 1
assert self.auth != a
def test_repr(self):
assert repr(self.auth).startswith('<Authorization')
def test_delete(self):
self.response('', 204)
self.delete(self.api)
self.assertRaises(github3.GitHubError, self.auth.delete)
self.not_called()
self.login()
assert self.auth.delete()
self.mock_assertions()
def test_update(self):
self.response('authorization', 200)
self.post(self.api)
data = {
'scopes': ['user']
}
self.conf = {'data': data}
self.assertRaises(github3.GitHubError, self.auth.update)
def sub_test():
assert self.auth.update(**data)
self.mock_assertions()
self.login()
assert self.auth.update() is False
self.not_called()
sub_test()
del(data['scopes'])
data['add_scopes'] = ['repo']
sub_test()
del(data['add_scopes'])
data['rm_scopes'] = ['user']
self.conf['data'] = {'remove_scopes': ['user']}
sub_test()
self.conf['data'] = data
del(data['rm_scopes'])
data['note'] = 'GitHub API'
data['note_url'] = 'http://example.com'
sub_test()