mirror of
https://github.com/khornberg/octokit.py
synced 2026-05-18 20:09:06 +03:00
Bug Fix: Correct type checking
This commit is contained in:
@@ -98,7 +98,7 @@ class Base(object):
|
||||
}
|
||||
installation_url = '{}/app/installations'.format(self.base_url)
|
||||
installations = requests.get(installation_url, headers=headers).json()
|
||||
self.installation_id = [x.get('id') for x in installations if x.get('app_id') == app_id].pop()
|
||||
self.installation_id = [x.get('id') for x in installations if str(x.get('app_id')) == app_id].pop()
|
||||
installation_token_url = '{}/installations/{}/access_tokens'.format(self.base_url, self.installation_id)
|
||||
response = requests.post(installation_token_url, headers=headers).json()
|
||||
return response['token'], response['expires_at']
|
||||
|
||||
+4
-4
@@ -66,7 +66,7 @@ class TestAuth(object):
|
||||
post.return_value = Request(json=lambda: {'token': 'v1.1f699f1069f60', 'expires_at': '2016-07-11T22:14:10Z'})
|
||||
with open(os.path.join(os.path.dirname(__file__), 'test.pem'), 'r') as f:
|
||||
private_key = f.read()
|
||||
sut = Octokit(auth='installation', app_id=42, private_key=private_key)
|
||||
sut = Octokit(auth='installation', app_id='42', private_key=private_key)
|
||||
assert sut.auth == 'installation'
|
||||
assert sut.token == 'v1.1f699f1069f60'
|
||||
assert sut.expires_at == '2016-07-11T22:14:10Z'
|
||||
@@ -77,9 +77,9 @@ class TestAuth(object):
|
||||
with pytest.raises(AssertionError):
|
||||
Octokit(auth='installation', app_id='')
|
||||
with pytest.raises(KeyError):
|
||||
Octokit(auth='installation', app_id=42)
|
||||
Octokit(auth='installation', app_id='42')
|
||||
with pytest.raises(AssertionError):
|
||||
Octokit(auth='installation', app_id=42, private_key='')
|
||||
Octokit(auth='installation', app_id='42', private_key='')
|
||||
|
||||
def test_installation_token_is_used_if_set(self, mocker):
|
||||
Request = namedtuple('Request', ['json'])
|
||||
@@ -89,7 +89,7 @@ class TestAuth(object):
|
||||
post.return_value = Request(json=lambda: {'token': 'v1.1f699f1069f60', 'expires_at': '2016-07-11T22:14:10Z'})
|
||||
with open(os.path.join(os.path.dirname(__file__), 'test.pem'), 'r') as f:
|
||||
private_key = f.read()
|
||||
sut = Octokit(auth='installation', app_id=42, private_key=private_key)
|
||||
sut = Octokit(auth='installation', app_id='42', private_key=private_key)
|
||||
assert sut.installation_id == 37
|
||||
get = mocker.patch('requests.get')
|
||||
sut.authorization.get(id=100)
|
||||
|
||||
Reference in New Issue
Block a user