Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests #29

Merged
merged 9 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,54 @@ name: Python package

on:
push:
branches: ["master"]
branches:
- "**"
pull_request:
branches: ["master"]
branches:
- "**"

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1 # to avoid failing tests because of API Rate limits
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest

- name: Install package
run: python setup.py install

- name: Testing Spot endpoints with pytest
env:
SPOT_API_KEY: ${{ secrets.SPOT_API_KEY }}
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
run: |
pytest tests/test_spot_rest.py

- name: Testing Futures endpoints with pytest
env:
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
run: |
echo "skip pytest because it would fail without valid API credentials" # pytest
pytest tests/test_futures_rest.py
12 changes: 6 additions & 6 deletions kraken/base_api/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from kraken.exceptions.exceptions import KrakenExceptions
except ModuleNotFoundError:
print('USING LOCAL MODULE')
sys.path.append('/Users/benjamin/repositories/Trading/python-kraken-sdk')
sys.path.append('/Users/benjamin/repositories/Finance/Kraken/python-kraken-sdk')
from kraken.exceptions.exceptions import KrakenExceptions

class KrakenErrorHandler():
Expand Down Expand Up @@ -253,11 +253,11 @@ def _request(self,
if method == 'PUT':
return self.__check_response_data(
self.__session.request(
method=method,
url=f'{self.url}{uri}',
params=str.encode(query_string),
headers=headers,
timeout=timeout
method=method,
url=f'{self.url}{uri}',
params=str.encode(query_string),
headers=headers,
timeout=timeout
),
return_raw
)
Expand Down
2 changes: 1 addition & 1 deletion kraken/spot/market/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_assets(self, assets=None, aclass: str=None) -> dict:
def get_tradable_asset_pair(self, pair: str, info=None) -> dict:
'''https://docs.kraken.com/rest/#operation/getTradableAssetPairs'''
params = {}
params['pair'] = self._to_str_list(pair)#','.join(pair)
params['pair'] = self._to_str_list(pair)
if info is not None: params['info'] = info

return self._request(method='GET', uri='/public/AssetPairs', params=params, auth=False)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# What packages are optional?
EXTRAS = {
'testing': ['pytest', 'tqdm']
'testing': ['pytest']
}

here = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -161,7 +161,7 @@ def run(self):
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(exclude=['tests', '*.tests', '*.tests.*', 'tests.*', '*.env*']),
packages=find_packages(exclude=['tests', '*.tests', '*.tests.*', 'tests.*', '*.env*', 'test_*']),
# If your package is a single module, use this instead of 'packages':
# py_modules=['mypackage'],

Expand Down
251 changes: 0 additions & 251 deletions tests/futures_rest_test.py

This file was deleted.

Loading