Skip to content

Commit 69c5c6a

Browse files
Update tests
1 parent 5c7f182 commit 69c5c6a

File tree

10 files changed

+154
-84
lines changed

10 files changed

+154
-84
lines changed

.github/workflows/_codecov.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ jobs:
9191
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
9292
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
9393
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
94-
run: |
95-
pytest -vv --cov=kraken --cov-report=xml:coverage.xml --cov-report=term tests
94+
run: pytest -vv -x --cov=kraken --cov-report=xml:coverage.xml --cov-report=term tests
9695

9796
- name: Export coverage report
9897
uses: actions/upload-artifact@v4

.github/workflows/_test_futures_private.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ jobs:
9898
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
9999
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
100100
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
101-
run: pytest -vv -m "futures and futures_auth and not futures_websocket" tests
101+
run: pytest -vv -x -m "futures and futures_auth and not futures_websocket" tests
102102

103103
- name: Testing Futures websocket client
104104
env:
105105
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
106106
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
107107
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
108108
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
109-
run: pytest -vv -m "futures and futures_auth and futures_websocket" tests
109+
run: pytest -vv -x -m "futures and futures_auth and futures_websocket" tests

.github/workflows/_test_futures_public.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
uv pip install $wheel -r requirements-dev.txt
8080
8181
- name: Testing Futures REST endpoints
82-
run: pytest -vv -m "futures and not futures_auth and not futures_websocket" tests
82+
run: pytest -vv -x -m "futures and not futures_auth and not futures_websocket" tests
8383

8484
- name: Testing Futures websocket endpoints
85-
run: pytest -vv -m "futures and not futures_auth and futures_websocket" tests
85+
run: pytest -vv -x -m "futures and not futures_auth and futures_websocket" tests

.github/workflows/_test_spot_private.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ jobs:
100100
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
101101
XSTOCKS_API_KEY: ${{ secrets.XSTOCKS_API_KEY }}
102102
XSTOCKS_SECRET_KEY: ${{ secrets.XSTOCKS_SECRET_KEY }}
103-
run: pytest -vv -m "spot and spot_auth and not spot_websocket" tests
103+
run: pytest -vv -x -m "spot and spot_auth and not spot_websocket" tests
104104

105105
- name: Testing Spot websocket client
106106
env:
107107
SPOT_API_KEY: ${{ secrets.SPOT_API_KEY }}
108108
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
109-
run: pytest -vv -m "spot and spot_auth and spot_websocket" tests
109+
run: pytest -vv -x -m "spot and spot_auth and spot_websocket" tests

.github/workflows/_test_spot_public.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
uv pip install $wheel -r requirements-dev.txt
8181
8282
- name: Testing Spot REST endpoints
83-
run: pytest -vv -m "spot and not spot_auth and not spot_websocket" tests
83+
run: pytest -vv -x -m "spot and not spot_auth and not spot_websocket" tests
8484

8585
- name: Testing Spot websocket endpoints
86-
run: pytest -vv -m "spot and not spot_auth and spot_websocket" tests
86+
run: pytest -vv -x -m "spot and not spot_auth and spot_websocket" tests

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.13.0
10+
rev: v0.13.3
1111
hooks:
1212
- id: ruff
1313
args:
1414
- --preview
1515
- --fix
1616
- --exit-non-zero-on-fix
1717
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v1.18.1
18+
rev: v1.18.2
1919
hooks:
2020
- id: mypy
2121
name: mypy
@@ -67,15 +67,15 @@ repos:
6767
- id: rst-inline-touching-normal
6868
- id: text-unicode-replacement-char
6969
- repo: https://github.com/psf/black
70-
rev: 25.1.0
70+
rev: 25.9.0
7171
hooks:
7272
- id: black
7373
- repo: https://github.com/rbubley/mirrors-prettier
7474
rev: v3.6.2
7575
hooks:
7676
- id: prettier
7777
- repo: https://github.com/PyCQA/isort # TODO: remove as soon as ruff is stable
78-
rev: 6.0.1
78+
rev: 6.1.0
7979
hooks:
8080
- id: isort
8181
args:

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ UV ?= uv
1010
PYTHON := python
1111
PYTEST := $(UV) run pytest
1212
PYTEST_OPTS := -vv --junit-xml=pytest.xml
13-
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term-missing
13+
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term-missing --cov-report=html
1414
TEST_DIR := tests
1515

1616
## ======= M A K E F I L E - T A R G E T S =====================================
@@ -92,11 +92,11 @@ doctest:
9292
cd docs && make doctest
9393

9494
## ======= M I S C E L A N I O U S =============================================
95-
## pre-commit Run the pre-commit targets
95+
## prek Run the pre-commit targets
9696
##
97-
.PHONY: pre-commit
98-
pre-commit:
99-
@pre-commit run -a
97+
.PHONY: prek
98+
prek:
99+
@prek run -a
100100

101101
## ruff Run ruff without fix
102102
##

src/kraken/cli.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import logging
2727
import sys
2828
from typing import TYPE_CHECKING, Any
29+
from urllib.parse import urlparse
2930

3031
from click import echo
3132
from cloup import (
@@ -52,7 +53,7 @@ def _print_version(
5253
param: Any, # noqa: ANN401, ARG001
5354
value: Any, # noqa: ANN401
5455
) -> None:
55-
"""Prints the version of the package"""
56+
"""Prints the version of the package."""
5657
if not value or ctx.resilient_parsing:
5758
return
5859
from importlib.metadata import version # noqa: PLC0415
@@ -62,8 +63,7 @@ def _print_version(
6263

6364

6465
def _get_base_url(url: str) -> str:
65-
"""Extracts the base URL from a full URL"""
66-
from urllib.parse import urlparse # noqa: PLC0415
66+
"""Extracts the base URL from a full URL."""
6767

6868
parsed_url = urlparse(url)
6969
if parsed_url.scheme and parsed_url.netloc:
@@ -72,16 +72,16 @@ def _get_base_url(url: str) -> str:
7272

7373

7474
def _get_uri_path(url: str) -> str:
75-
"""Extracts the URI path from a full URL or returns the URL if it's already a path"""
76-
from urllib.parse import urlparse # noqa: PLC0415
75+
"""
76+
Extracts the URI path from a full URL or returns the URL if it's already a
77+
path.
78+
"""
7779

7880
parsed_url = urlparse(url)
7981
if parsed_url.scheme and parsed_url.netloc:
8082
path = parsed_url.path
8183
if parsed_url.query:
8284
path += f"?{parsed_url.query}"
83-
if parsed_url.fragment:
84-
path += f"#{parsed_url.fragment}"
8585
return path
8686
return url
8787

@@ -188,9 +188,9 @@ def spot(ctx: Context, url: str, **kwargs: dict) -> None: # noqa: ARG001
188188
)
189189
)
190190
except JSONDecodeError as exc:
191-
LOG.error(f"Could not parse the passed data. {exc}") # noqa: G004
191+
LOG.error("Could not parse the passed data. %s", exc)
192192
except Exception as exc: # noqa: BLE001
193-
LOG.error(f"Exception occurred: {exc}") # noqa: G004
193+
LOG.error("Exception occurred: %s", exc)
194194
sys.exit(1)
195195
else:
196196
echo(response)
@@ -266,9 +266,9 @@ def futures(ctx: Context, url: str, **kwargs: dict) -> None: # noqa: ARG001
266266
)
267267
)
268268
except JSONDecodeError as exc:
269-
LOG.error(f"Could not parse the passed data. {exc}") # noqa: G004
269+
LOG.error("Could not parse the passed data. %s", exc)
270270
except Exception as exc: # noqa: BLE001
271-
LOG.error(f"Exception occurred: {exc}") # noqa: G004
271+
LOG.error("Exception occurred: %s", exc)
272272
sys.exit(1)
273273
else:
274274
echo(response)

tests/cli/conftest.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from __future__ import annotations
1111

1212
import os
13+
from typing import Generator
1314

1415
import pytest
1516
from click.testing import CliRunner
@@ -22,12 +23,23 @@ def cli_runner() -> CliRunner:
2223

2324

2425
@pytest.fixture
25-
def _with_cli_env_vars() -> None:
26+
def with_cli_env_vars() -> Generator:
2627
"""Setup some environment variables for th CLI tests"""
27-
os.environ["KRAKEN_SPOT_API_KEY"] = os.getenv("SPOT_API_KEY", "")
28-
os.environ["KRAKEN_SPOT_SECRET_KEY"] = os.getenv("SPOT_SECRET_KEY", "")
29-
os.environ["KRAKEN_FUTURES_API_KEY"] = os.getenv("FUTURES_API_KEY", "")
30-
os.environ["KRAKEN_FUTURES_SECRET_KEY"] = os.getenv("FUTURES_SECRET_KEY", "")
28+
29+
if not all(
30+
(
31+
spot_api_key := os.getenv("SPOT_API_KEY"),
32+
spot_secret_key := os.getenv("SPOT_SECRET_KEY"),
33+
futures_api_key := os.getenv("FUTURES_API_KEY"),
34+
futures_secret_key := os.getenv("FUTURES_SECRET_KEY"),
35+
),
36+
):
37+
pytest.fail("No API keys provided for CLI tests!")
38+
39+
os.environ["KRAKEN_SPOT_API_KEY"] = spot_api_key
40+
os.environ["KRAKEN_SPOT_SECRET_KEY"] = spot_secret_key
41+
os.environ["KRAKEN_FUTURES_API_KEY"] = futures_api_key
42+
os.environ["KRAKEN_FUTURES_SECRET_KEY"] = futures_secret_key
3143

3244
yield
3345

0 commit comments

Comments
 (0)