-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add support for marshalling/unmarshalling to/from json -> dataclasses. - switch to using github actions - remove deprecated features - Allow header authentication to pass in extra headers required for authenticating the client.
- Loading branch information
1 parent
9d55ed2
commit 476f233
Showing
23 changed files
with
712 additions
and
248 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Unit Tests | ||
|
||
on: push | ||
|
||
jobs: | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox | ||
- name: Lint Checks | ||
run: | | ||
tox -e lint | ||
- name: Unit Tests | ||
run: | | ||
tox -e unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Python test and deploy | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
|
||
jobs: | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox | ||
- name: Lint Checks | ||
run: | | ||
tox -e lint | ||
- name: Unit Tests | ||
run: | | ||
tox -e unittest | ||
deploy: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set Up Build | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e .[deploy] | ||
- name: Update RC Version | ||
run: | | ||
python scripts/update_version.py ${GITHUB_REF} | ||
- name: Build Dist | ||
run: | | ||
rm -rf dist/* | ||
python setup.py sdist | ||
- name: Publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python scripts/upload_new_package.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
recursive-include apiclient * | ||
include VERSION | ||
|
||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[co] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Optional, TypeVar | ||
|
||
from jsonmarshal import marshal, unmarshal | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
def unmarshal_response(schema: T, date_fmt: Optional[str] = None, datetime_fmt: Optional[str] = None): | ||
"""Decorator to unmarshal the response json into the provided dataclass.""" | ||
|
||
def decorator(func) -> T: | ||
def wrap(*args, **kwargs) -> T: | ||
response = func(*args, **kwargs) | ||
return unmarshal(response, schema, date_fmt=date_fmt, datetime_fmt=datetime_fmt) | ||
|
||
return wrap | ||
|
||
return decorator | ||
|
||
|
||
def marshal_request(date_fmt: Optional[str] = None, datetime_fmt: Optional[str] = None): | ||
"""Decorator to marshal the request from a dataclass into valid json.""" | ||
|
||
def decorator(func) -> T: | ||
def wrap(endpoint: str, data: T, *args, **kwargs): | ||
marshalled = marshal(data, date_fmt=date_fmt, datetime_fmt=datetime_fmt) | ||
return func(endpoint, marshalled, *args, **kwargs) | ||
|
||
return wrap | ||
|
||
return decorator |
Oops, something went wrong.