Skip to content

test: expand local (mocked) API test coverage across all SDK modules#101

Merged
martinkersner merged 3 commits into
mainfrom
issue-97-expand-local-mocked-test-coverage
Jun 30, 2026
Merged

test: expand local (mocked) API test coverage across all SDK modules#101
martinkersner merged 3 commits into
mainfrom
issue-97-expand-local-mocked-test-coverage

Conversation

@martinkersner

@martinkersner martinkersner commented Jun 30, 2026

Copy link
Copy Markdown
Member

Closes #97

Summary

Adds a broad local-only (responses-mocked) test suite so every SDK module is exercised offline with no DATAMAXI_API_KEY and no real network, and wires that suite into CI. Previously only api, error, liquidation, open_interest had any mocked coverage; a regression in the other modules passed CI silently. Each new test file covers happy-path response shape (DataFrame vs dict/list + a key field), wire query-param construction (incl. snake_case/camelCase translation), and error handling (ClientError on 4xx, ServerError on 5xx). test_integration.py is left untouched.

Modules now covered (new mocked tests)

  • cex aggregator wiring (cex)
  • cex_candle, cex_ticker, cex_fee, cex_wallet_status, cex_announcement, cex_token, cex_symbol
  • forex, premium, funding_rate
  • naver, telegram
  • liquidation / open_interest — added return-shape + error coverage (param translation already in test_query_params.py)

CI

Adds a keyless "Run offline mocked tests" step (after flake8) to .github/workflows/python-package.yml:
python -m pytest tests/ -k "not integration" -q. The -k "not integration" filter excludes the live test_integration.py; the keyed test_call.py tests skip cleanly without a key, so CI stays green with no secrets. Coverage stays a local-only concern (no --cov in CI).

Test plan

unset DATAMAXI_API_KEY API_KEY
python -m pytest tests/ -k "not integration" -q

Result: 108 passed, 11 skipped (skipped = keyed test_call.py), integration deselected. Fully offline, no API key.

Coverage (--cov=datamaxi): 34% → 76% local-only.

Lint: black + flake8 clean on all new files.

Cover cex aggregator wiring + candle/ticker/fee/wallet_status/
announcement/token/symbol: happy-path shape, wire query params,
ClientError/ServerError. Offline, no API key (responses-mocked).
Cover forex/premium/funding_rate/naver/telegram plus return-shape and
error coverage for liquidation/open_interest: happy-path shape, wire
query params, ClientError/ServerError. Offline, no API key.

Local coverage 34% -> 76%.
@martinkersner martinkersner self-assigned this Jun 30, 2026
Add a keyless pytest step after flake8 running
`pytest tests/ -k "not integration"`. Excludes the live
test_integration.py; keyed test_call.py tests skip with no key.
@martinkersner martinkersner merged commit 6536276 into main Jun 30, 2026
7 checks passed
@martinkersner martinkersner deleted the issue-97-expand-local-mocked-test-coverage branch June 30, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand local (mocked) API test coverage across all SDK modules

1 participant