-
Notifications
You must be signed in to change notification settings - Fork 406
/
Copy pathtest_auths.py
69 lines (61 loc) · 2.59 KB
/
test_auths.py
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
69
"""Integration tests for the github3.auths module."""
import github3
from .helper import IntegrationHelper
class TestAuthorization(IntegrationHelper):
"""Integration tests for the Authorization class."""
def test_add_scopes(self):
"""Test the ability to add scopes to an authorization."""
self.basic_login()
cassette_name = self.cassette_name("add_scopes")
with self.recorder.use_cassette(cassette_name):
created_auth = self.gh.authorize(
username=self.user,
password=self.password,
scopes=["gist"],
note="testing github3.py",
)
auth = self.gh.authorization(created_auth.id)
assert isinstance(auth, github3.auths.Authorization)
assert auth.add_scopes(["user"]) is True
auth.delete()
def test_delete(self):
"""Test the ability to delete an authorization."""
self.basic_login()
cassette_name = self.cassette_name("delete")
with self.recorder.use_cassette(cassette_name):
auth = self.gh.authorize(
username=self.user,
password=self.password,
scopes=["gist"],
note="testing github3.py",
)
assert isinstance(auth, github3.auths.Authorization)
assert auth.delete() is True
def test_remove_scopes(self):
"""Test the ability to remove scopes from an authorization."""
self.basic_login()
cassette_name = self.cassette_name("remove_scopes")
with self.recorder.use_cassette(cassette_name):
auth = self.gh.authorize(
username=self.user,
password=self.password,
scopes=["gist", "user", "public_repo"],
note="testing github3.py",
)
assert isinstance(auth, github3.auths.Authorization)
assert auth.remove_scopes(["user", "public_repo"]) is True
auth.delete()
def test_replace_scopes(self):
"""Test the ability to replace scopes on an authorization."""
self.basic_login()
cassette_name = self.cassette_name("replace_scopes")
with self.recorder.use_cassette(cassette_name):
auth = self.gh.authorize(
username=self.user,
password=self.password,
scopes=["gist"],
note="testing github3.py",
)
assert isinstance(auth, github3.auths.Authorization)
assert auth.replace_scopes(["user", "public_repo"]) is True
auth.delete()