Skip to content

Commit

Permalink
Merge pull request #50 from khornberg/feature/routes
Browse files Browse the repository at this point in the history
Refactor: Drop python 3.4 support
  • Loading branch information
khornberg authored Jan 3, 2019
2 parents 837b39b + 14d8f98 commit 8fd816e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: python
dist: xenial
python:
- '3.6'
sudo: false
Expand All @@ -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
Expand Down
13 changes: 9 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
===========

Expand All @@ -158,7 +163,7 @@ The :code:`octokit` client based on the available `route data <https://github.co

::

[ ] Periodically, check if ``routes.json`` has changed and if so fetch and open a PR for it to be merged
[x] Periodically, check if ``routes.json`` has changed and if so fetch and open a PR for it to be merged

[ ] Periodically, check if ``webhook-names.json`` has changed and if so fetch and open a PR for it to be merged

Expand Down Expand Up @@ -193,7 +198,7 @@ Best Practices

[ ] handles rate limiting

[ ] pagination
[x] pagination

Documentation
-------------
Expand All @@ -207,7 +212,7 @@ Deployment

::

[ ] Deploy wheels
[x] Deploy wheels
[ ] Make GitHub releases work


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
python-jose==3.0.1
requests==2.21.0
octokitpy-routes==0.0.5
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def read(*names, **kwargs):

setup(
name='octokitpy',
version='0.9.2',
version='0.10.0',
license='MIT license',
description='Python client for GitHub API',
long_description='%s\n%s' % (
Expand Down
3 changes: 2 additions & 1 deletion src/octokit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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+)"')

Expand Down Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions tests/test_octokit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fd816e

Please sign in to comment.