mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Support non-default URLs in GithubIntegration (#1229)
The get_installation() method of GithubIntegration was hardcoded to always use the default URL of api.github.com, making it impossible to fetch the installation of an GitHub Enterprise installation.
This commit is contained in:
+1
-1
@@ -790,7 +790,7 @@ class GithubIntegration(object):
|
||||
}
|
||||
|
||||
response = requests.get(
|
||||
"{}/repos/{}/{}/installation".format(DEFAULT_BASE_URL, owner, repo),
|
||||
"{}/repos/{}/{}/installation".format(self.base_url, owner, repo),
|
||||
headers=headers
|
||||
)
|
||||
response_dict = response.json()
|
||||
|
||||
@@ -84,6 +84,7 @@ class GithubIntegration(unittest.TestCase):
|
||||
def __init__(self):
|
||||
self.args = tuple()
|
||||
self.kwargs = dict()
|
||||
self.calls = []
|
||||
|
||||
@property
|
||||
def status_code(self):
|
||||
@@ -120,6 +121,7 @@ class GithubIntegration(unittest.TestCase):
|
||||
)
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
self.calls.append((args, kwargs))
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
return self
|
||||
@@ -167,9 +169,18 @@ class GithubIntegration(unittest.TestCase):
|
||||
integr = GithubIntegration("11111", private_key)
|
||||
inst = integr.get_installation("foo", "bar")
|
||||
self.assertEqual(
|
||||
inst.id.value,
|
||||
111111
|
||||
)
|
||||
self.get_mock.calls[0][0],
|
||||
('https://api.github.com/repos/foo/bar/installation',))
|
||||
self.assertEqual(inst.id.value, 111111)
|
||||
|
||||
def test_get_installation_custom_base_url(self):
|
||||
from github import GithubIntegration
|
||||
integr = GithubIntegration("11111", private_key, base_url='https://corp.com/v3')
|
||||
inst = integr.get_installation("foo", "bar")
|
||||
self.assertEqual(
|
||||
self.get_mock.calls[0][0],
|
||||
('https://corp.com/v3/repos/foo/bar/installation',))
|
||||
self.assertEqual(inst.id.value, 111111)
|
||||
|
||||
def tearDown(self):
|
||||
GithubObject.setCheckAfterInitFlag(self.origin_check_after_init_flag)
|
||||
|
||||
Reference in New Issue
Block a user