Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit012c842

Browse files
committed
Allow for a callback to be specified
-Closessigmavirus24#212
1 parentfbc140b commit012c842

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

‎github3/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
defauthorize(login,password,scopes,note='',note_url='',client_id='',
17-
client_secret=''):
17+
client_secret='',two_factor_callback=None):
1818
"""Obtain an authorization token for the GitHub API.
1919
2020
:param str login: (required)
@@ -27,9 +27,13 @@ def authorize(login, password, scopes, note='', note_url='', client_id='',
2727
to create a token
2828
:param str client_secret: (optional), 40 character OAuth client secret for
2929
which to create the token
30+
:param func two_factor_callback: (optional), function to call when a
31+
Two-Factor Authentication code needs to be provided by the user.
3032
:returns: :class:`Authorization <Authorization>`
3133
3234
"""
35+
gh=GitHub()
36+
gh.login(two_factor_callback=two_factor_callback)
3337
returngh.authorize(login,password,scopes,note,note_url,client_id,
3438
client_secret)
3539

‎tests/test_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ def tearDown(self):
1414
deftest_authorize(self):
1515
args= ('login','password', ['scope1'],'note','note_url.com','',
1616
'')
17-
github3.authorize(*args)
18-
self.gh.authorize.assert_called_with(*args)
17+
withpatch.object(github3.api.GitHub,'authorize')asauthorize:
18+
github3.authorize(*args)
19+
authorize.assert_called_once_with(*args)
1920

2021
deftest_login(self):
2122
args= ('login','password',None,None)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp