diff --git a/.travis.yml b/.travis.yml index 36073ee..98510c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +dist: xenial python: - '3.6' sudo: false @@ -12,15 +13,15 @@ env: - TOXENV=docs matrix: include: + - python: '3.7' + env: + - TOXENV=py37 - python: '3.6' env: - TOXENV=py36 - python: '3.5' env: - TOXENV=py35 - - python: '3.4' - env: - - TOXENV=py34 before_install: - python --version - uname -a diff --git a/README.rst b/README.rst index 10116b4..9b60903 100644 --- a/README.rst +++ b/README.rst @@ -57,7 +57,7 @@ Python client for GitHub API Installation ============ -**requires python 3.4+** +**requires python 3.5+** Yes that is opinionated. Python 2 is near the end of the life and this is a new project. @@ -133,6 +133,11 @@ For applications provide the application id either from the ping webhook or the The :code:`private_key` is a string of your private key provided for the application. The :code:`app` scheme will use the application id and private key to get a token for the first installation id of the application. +API Schema/Routes/Specifications +-------------------------------- + +One can instantiate the ``Octokit`` with ``routes=specification`` where the ``specification`` is one of ``api.github.com``, ``ghe-2.15``, etc. + TODOs =========== @@ -158,7 +163,7 @@ The :code:`octokit` client based on the available `route data ; 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) diff --git a/tests/test_methods.py b/tests/test_methods.py index 06cf808..3fc8463 100644 --- a/tests/test_methods.py +++ b/tests/test_methods.py @@ -18,8 +18,7 @@ def test_client_methods_are_lower_case(self): pass # ignore non-class attributes def test_method_has_doc_string(self): - assert Octokit( - ).oauth_authorizations.list_grants.__doc__ == """You can use this API to list the set of OAuth applications that have been granted access to your account. Unlike the [list your authorizations](https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations) API, this API does not manage individual tokens. This API will return one entry for each OAuth application that has been granted access to your account, regardless of the number of tokens an application has generated for your user. The list of OAuth applications returned matches what is shown on [the application authorizations settings screen within GitHub](https://github.com/settings/applications#authorized). The `scopes` returned are the union of scopes authorized for the application. For example, if an application has one token with `repo` scope and another token with `user` scope, the grant will return `[\"repo\", \"user\"]`.""" # noqa E501 + assert Octokit().oauth_authorizations.list_grants.__doc__ == self.doc_string def test_method_has_name_string(self): assert Octokit().oauth_authorizations.list_grants.__name__ == 'list_grants' @@ -261,3 +260,7 @@ def test_dictionary_keys_are_validated(self, mocker): data=json.dumps(data, sort_keys=True), headers=headers ) + + @property + def doc_string(self): + return """You can use this API to list the set of OAuth applications that have been granted access to your account. Unlike the [list your authorizations](https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations) API, this API does not manage individual tokens. This API will return one entry for each OAuth application that has been granted access to your account, regardless of the number of tokens an application has generated for your user. The list of OAuth applications returned matches what is shown on [the application authorizations settings screen within GitHub](https://github.com/settings/applications#authorized). The `scopes` returned are the union of scopes authorized for the application. For example, if an application has one token with `repo` scope and another token with `user` scope, the grant will return `[\"repo\", \"user\"]`.""" # noqa E501 diff --git a/tests/test_octokit.py b/tests/test_octokit.py index eb69a57..a629370 100644 --- a/tests/test_octokit.py +++ b/tests/test_octokit.py @@ -47,3 +47,12 @@ def test_pagination(self): 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__ diff --git a/tox.ini b/tox.ini index 477460b..b878b1b 100644 --- a/tox.ini +++ b/tox.ini @@ -3,14 +3,14 @@ [tox] envlist = check, - {py36,py35,py34}, + {py37,py36,py35}, docs [testenv] basepython = + py37: {env:TOXPYTHON:python3.7} py36: {env:TOXPYTHON:python3.6} py35: {env:TOXPYTHON:python3.5} - py34: {env:TOXPYTHON:python3.4} {bootstrap,check,docs}: {env:TOXPYTHON:python3} setenv = PYTHONPATH={toxinidir}/tests