Skip to content

Commit

Permalink
Improve test suite and remove unused workflows (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Aug 3, 2024
1 parent 23ebb6a commit a151b44
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 225 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ What has being changed - provide code snippets, examples, screenshots, lists -
any kind of information hat helps to understand the update.

**Make sure to address all topics of the [self-review
checklist](https://github.com/github/docs/blob/main/contributing/self-review.md#self-review).**
checklist](https://github.com/btschwertfeger/python-kraken-sdk/blob/master/.github/self-review.md).**

Closes: Don't forget to link an existing issue for your change. If there is no
open issue for your change - create one to make it more likely that his update
Expand Down
30 changes: 12 additions & 18 deletions .github/self-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,24 @@ must be addressed before a PR will be accepted.

- [ ] **All** pre-commit hooks must run through - successfully.
- [ ] Make sure that the changes confirm the coding style of the
[python-kraken-sdk](https://github.com/btschwertfeger/python-kraken-sdk). Most
issues will be resolve through the pre-commit hooks.
[python-kraken-sdk](https://github.com/btschwertfeger/python-kraken-sdk).
Most issues will be resolve through the pre-commit hooks.
- [ ] Also take care to follow the community guidelines and the [Code of
Conduct](./CODE_OF_CONDUCT.md).
- [ ] Self-review your changes to detect typos, syntax errors and any kind of
unwanted behavior.
- [ ] If you changed the source code you have to **ensure that all unit tests
run through**. If you added a new function you also have to **write a test**
for that. Also make sure to **follow the doc string style** of the package and
**provide at least one working example** within a function doc string. This is
important since doc strings will be reflected within the documentation.
run through**. If you added a new function you also have to **write a
test** for that. Also make sure to **follow the doc string style** of the
package and **provide at least one working example** within a function doc
string. This is important since doc strings will be reflected within the
documentation.
- [ ] Take your time to prepare your code before creating a PR. A good PR will
save a lot of time for everyone.
- [ ] There are several workflows/actions within this repository. Any relevant
workflow must be run successfully within your fork. In the following these
workflows are listed, but **please also read the respective workflow files to
get further information**.
- PR Manual Pre-Commit (`manual_pre_commit.yaml`): This workflow must be green
in any case.
- PR Manual Build (`manual_build.yaml`): Must be green in any case.
- PR Manual CodeQL (`manual_codeql.yaml`): same here
- PR Manual Test Spot (`manual_test_spot.yaml`): If any Spot related change
happened
- PR Manual Test Futures (`manual_test_futures.yaml`): For any Futures related
changes
- [ ] There are several workflows/actions within this repository. Relevant
workflows must be run successfully within your fork. In the following
these workflows are listed, but **please also read the respective workflow
files to get further information**. Actions must be enabled within the
fork, so that workflows can run within the context of a PR.
- CI/CD (`cicd.yaml`): Can be used to run all actions at once - but requires
having API keys for Spot, Futures and the Futures demo environment.
27 changes: 0 additions & 27 deletions .github/workflows/manual_build.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/manual_codeql.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/manual_pre_commit.yaml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/manual_test_futures.yaml

This file was deleted.

64 changes: 0 additions & 64 deletions .github/workflows/manual_test_spot.yaml

This file was deleted.

15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Changelog

## [Unreleased](https://github.com/btschwertfeger/python-kraken-sdk/tree/HEAD)
## [v3.1.0](https://github.com/btschwertfeger/python-kraken-sdk/tree/v3.1.0) (2024-07-31)

[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v3.0.0...HEAD)
[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v3.0.0...v3.1.0)

**Implemented enhancements:**

- Add proxy support for futures and spot clients \(async and sync\) [\#257](https://github.com/btschwertfeger/python-kraken-sdk/pull/257) ([Graeme22](https://github.com/Graeme22))

Uncategorized merged pull requests:

- Bump github/codeql-action from 3.25.13 to 3.25.15 [\#260](https://github.com/btschwertfeger/python-kraken-sdk/pull/260) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump ossf/scorecard-action from 2.3.3 to 2.4.0 [\#259](https://github.com/btschwertfeger/python-kraken-sdk/pull/259) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump step-security/harden-runner from 2.8.1 to 2.9.0 [\#255](https://github.com/btschwertfeger/python-kraken-sdk/pull/255) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump github/codeql-action from 3.25.12 to 3.25.13 [\#254](https://github.com/btschwertfeger/python-kraken-sdk/pull/254) ([dependabot[bot]](https://github.com/apps/dependabot))
- Skip test which requires to be executed from an institutional account [\#253](https://github.com/btschwertfeger/python-kraken-sdk/pull/253) ([btschwertfeger](https://github.com/btschwertfeger))
- Bump actions/dependency-review-action from 4.3.3 to 4.3.4 [\#251](https://github.com/btschwertfeger/python-kraken-sdk/pull/251) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump github/codeql-action from 3.25.11 to 3.25.12 [\#250](https://github.com/btschwertfeger/python-kraken-sdk/pull/250) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump actions/setup-python from 5.1.0 to 5.1.1 [\#249](https://github.com/btschwertfeger/python-kraken-sdk/pull/249) ([dependabot[bot]](https://github.com/apps/dependabot))
Expand All @@ -14,6 +23,8 @@ Uncategorized merged pull requests:
- Bump github/codeql-action from 2.2.4 to 3.25.11 [\#246](https://github.com/btschwertfeger/python-kraken-sdk/pull/246) ([dependabot[bot]](https://github.com/apps/dependabot))
- CI: Change rules for harden-runner job in codeql [\#245](https://github.com/btschwertfeger/python-kraken-sdk/pull/245) ([btschwertfeger](https://github.com/btschwertfeger))
- Bump actions/dependency-review-action from 2.5.1 to 4.3.3 [\#243](https://github.com/btschwertfeger/python-kraken-sdk/pull/243) ([dependabot[bot]](https://github.com/apps/dependabot))
- Update the CI trigger rules to allow workflow runs on pull requests from outside this repository [\#262](https://github.com/btschwertfeger/python-kraken-sdk/pull/262) ([btschwertfeger](https://github.com/btschwertfeger))
- Update the CI environment URL [\#258](https://github.com/btschwertfeger/python-kraken-sdk/pull/258) ([btschwertfeger](https://github.com/btschwertfeger))

## [v3.0.0](https://github.com/btschwertfeger/python-kraken-sdk/tree/v3.0.0) (2024-06-23)

Expand Down
36 changes: 23 additions & 13 deletions tests/spot/test_spot_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import logging
import re
from asyncio import run as asyncio_run
from asyncio import sleep as async_sleep
from copy import deepcopy
Expand Down Expand Up @@ -212,7 +213,8 @@ async def create_client() -> None:

asyncio_run(create_client())

assert '{"method": "pong", "req_id": 123456789, "time_in":' in caplog.text
assert '{"method": "pong", "req_id": 123456789' in caplog.text
assert '"success": false' not in caplog.text


@pytest.mark.spot()
Expand All @@ -236,8 +238,9 @@ async def test_subscription() -> None:
assert (
'{"method": "subscribe", "req_id": 12345678, "result": {"channel":'
' "ticker", "event_trigger": "trades", "snapshot": true, "symbol":'
' "BTC/USD"}, "success": true, "time_in":' in caplog.text
' "BTC/USD"}, "success": true' in caplog.text
)
assert '"success": false' not in caplog.text


@pytest.mark.spot()
Expand Down Expand Up @@ -289,11 +292,11 @@ async def test_subscription() -> None:

asyncio_run(test_subscription())

for phrase in (
'{"method": "subscribe", "req_id": 123456789, "result": {"channel": "executions", "maxratecount": 180, "snapshot": true,', # for some reason they provide a "warnings" key
'"success": true, "time_in": ',
):
assert phrase in caplog.text
assert re.search(
r'\{"method": "subscribe", "req_id": 123456789, "result": \{"channel": "executions".*"success": true',
caplog.text,
)
assert '"success": false' not in caplog.text


@pytest.mark.spot()
Expand All @@ -316,11 +319,12 @@ async def test_unsubscribe() -> None:
asyncio_run(test_unsubscribe())

for expected in (
'{"method": "subscribe", "req_id": 123456789, "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in": ',
'{"method": "subscribe", "req_id": 123456789, "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true',
'{"channel": "ticker", "type": "snapshot", "data": [{"symbol": "BTC/USD", ',
'{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "ticker", "event_trigger": "trades", "symbol": "BTC/USD"}, "success": true, "time_in": ',
'{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "ticker", "event_trigger": "trades", "symbol": "BTC/USD"}, "success": true',
):
assert expected in caplog.text
assert '"success": false' not in caplog.text


@pytest.mark.spot()
Expand Down Expand Up @@ -380,8 +384,8 @@ async def check_unsubscribe() -> None:
asyncio_run(check_unsubscribe())

for expected in (
'{"method": "subscribe", "req_id": 123456789, "result": {"channel": "executions", "maxratecount": 180, "snapshot": true', # , "success": true, "time_in": ',
'{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "executions"}, "success": true, "time_in": ',
'{"method": "subscribe", "req_id": 123456789, "result": {"channel": "executions"',
'{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "executions"}, "success": true',
):
assert expected in caplog.text
assert '"success": false' not in caplog.text
Expand Down Expand Up @@ -512,9 +516,15 @@ async def check_reconnect() -> None:
"got an exception sent 1000 (OK); then received 1000 (OK)",
"Recover public subscriptions [{'channel': 'ticker', 'event_trigger': 'trades', 'snapshot': True, 'symbol': ['BTC/USD']}]: waiting",
"Recover public subscriptions [{'channel': 'ticker', 'event_trigger': 'trades', 'snapshot': True, 'symbol': ['BTC/USD']}]: done",
"Recover authenticated subscriptions [{'channel': 'executions', 'snapshot': True}]: waiting",
"Recover authenticated subscriptions [{'channel': 'executions', 'snapshot': True}]: done",
):
assert phrase in caplog.text

assert re.search(
r"Recover authenticated subscriptions .*'channel': 'executions'.* waiting",
caplog.text,
)
assert re.search(
r"Recover authenticated subscriptions .*'channel': 'executions'.* done",
caplog.text,
)
assert '"success": False' not in caplog.text

0 comments on commit a151b44

Please sign in to comment.