Feature: Use route data

Data is updated from @octokit/routes -> npm -> octokitpy-routes -> pypi
This commit is contained in:
Kyle Hornberg
2019-01-02 14:39:28 -06:00
parent 7fa46f114a
commit ff6203be27
2 changed files with 11 additions and 1 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import requests
from jose import jwt
from octokit import errors
from octokit import utils
from routes import specifications
page_regex = re.compile(r'[\?\&]page=(\d+)[_&=\w\d]*>; rel="(\w+)"')
@@ -164,7 +165,7 @@ class Octokit(Base):
def __init__(self, *args, **kwargs):
super().__init__()
self._create(utils.get_json_data('index.json'))
self._create(specifications[kwargs.get('routes', 'api.github.com')])
self._setup_authentication(kwargs)
self._attribute_cache = defaultdict(dict)
+9
View File
@@ -47,3 +47,12 @@ class TestOctokit(object):
assert next(p) == {'page': 2, 'kwargs': {'param': 'value'}}
assert next(p) == {'page': 3, 'kwargs': {'param': 'value'}}
assert next(p) == {'page': 4, 'kwargs': {'param': 'value'}}
def test_can_speficy_the_route_specifications_used(self):
from octokit import Octokit
octokit = Octokit(routes='ghe-2.15')
assert '/enterprise/2.15' in octokit.issues.create.__doc__
octokit = Octokit()
assert '/developer.github.com' in octokit.issues.create.__doc__
octokit = Octokit(routes='api.github.com')
assert '/developer.github.com' in octokit.issues.create.__doc__