forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.py
More file actions
152 lines (119 loc) · 4.97 KB
/
test_api.py
File metadata and controls
152 lines (119 loc) · 4.97 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import github3
from unittest import TestCase
#from .utils.mock import patch, NonCallableMock
from .utils import mock
class TestAPI(TestCase):
def setUp(self):
self.mock = mock.patch('github3.api.gh', autospec=github3.GitHub)
self.gh = self.mock.start()
def tearDown(self):
self.mock.stop()
def test_authorize(self):
args = ('login', 'password', ['scope1'], 'note', 'note_url.com', '',
'')
with mock.patch.object(github3.api.GitHub, 'authorize') as authorize:
github3.authorize(*args)
authorize.assert_called_once_with(*args)
def test_login(self):
args = ('login', 'password', None, None)
with mock.patch.object(github3.api.GitHub, 'login') as login:
g = github3.login(*args)
assert isinstance(g, github3.github.GitHub)
assert not isinstance(g, github3.github.GitHubEnterprise)
login.assert_called_with(*args)
def test_enterprise_login(self):
args = ('login', 'password', None, 'http://ghe.invalid/', None)
with mock.patch.object(github3.api.GitHubEnterprise, 'login') as login:
g = github3.login(*args)
assert isinstance(g, github3.github.GitHubEnterprise)
login.assert_called_with('login', 'password', None, None)
def test_gist(self):
args = (123,)
github3.gist(*args)
self.gh.gist.assert_called_with(*args)
def test_gitignore_template(self):
args = ('Python',)
github3.gitignore_template(*args)
self.gh.gitignore_template.assert_called_with(*args)
def test_gitignore_templates(self):
github3.gitignore_templates()
assert self.gh.gitignore_templates.called is True
def test_iter_all_repos(self):
github3.iter_all_repos()
self.gh.iter_all_repos.assert_called_with(-1, None)
def test_iter_all_users(self):
github3.iter_all_users()
self.gh.iter_all_users.assert_called_with(-1, None)
def test_iter_events(self):
github3.iter_events()
self.gh.iter_events.assert_called_with(-1, None)
def test_iter_followers(self):
github3.iter_followers('login')
self.gh.iter_followers.assert_called_with('login', -1, None)
def test_iter_following(self):
github3.iter_following('login')
self.gh.iter_following.assert_called_with('login', -1, None)
def test_iter_gists(self):
github3.iter_gists()
self.gh.iter_gists.assert_called_with(None, -1, None)
def test_iter_repo_issues(self):
args = ('owner', 'repository', None, None, None, None, None, None,
None, None, -1, None)
github3.iter_repo_issues(*args)
self.gh.iter_repo_issues.assert_called_with(*args)
github3.iter_repo_issues(None, None)
def test_iter_orgs(self):
args = ('login', -1, None)
github3.iter_orgs(*args)
self.gh.iter_orgs.assert_called_with(*args)
def test_iter_user_repos(self):
args = ('login', None, None, None, -1, None)
github3.iter_user_repos('login')
self.gh.iter_user_repos.assert_called_with(*args)
github3.iter_user_repos(None)
def test_iter_starred(self):
github3.iter_starred('login')
self.gh.iter_starred.assert_called_with('login', -1, None)
def test_iter_subcriptions(self):
github3.iter_subscriptions('login')
self.gh.iter_subscriptions.assert_called_with('login', -1, None)
def test_create_gist(self):
args = ('description', {'files': ['files']})
github3.create_gist(*args)
self.gh.create_gist.assert_called_with(*args)
def test_issue(self):
args = ('owner', 'repo', 1)
github3.issue(*args)
self.gh.issue.assert_called_with(*args)
def test_markdown(self):
args = ('text', '', '', False)
github3.markdown(*args)
self.gh.markdown.assert_called_with(*args)
def test_octocat(self):
github3.octocat()
assert self.gh.octocat.called is True
def test_organization(self):
github3.organization('login')
self.gh.organization.assert_called_with('login')
def test_pull_request(self):
args = ('owner', 'repo', 1)
github3.pull_request(*args)
self.gh.pull_request.assert_called_with(*args)
def test_repository(self):
args = ('owner', 'repo')
github3.repository(*args)
self.gh.repository.assert_called_with(*args)
def test_user(self):
github3.user('login')
self.gh.user.assert_called_with('login')
def test_rate_limit(self):
github3.rate_limit()
self.gh.rate_limit.assert_called_once_with()
def test_ratelimit_remaining(self):
# This prevents a regression in the API
# See 81c800658db43f86419b9c0764fc16aad3d60007
self.gh.ratelimit_remaining = mock.NonCallableMock()
github3.ratelimit_remaining()
def test_zen(self):
github3.zen()
assert self.gh.zen.called is True