Skip to content

test(Preview): Add preview endpoint tests#21

Merged
szemyd merged 3 commits intomainfrom
feature/test-preview-endpoint
Apr 10, 2026
Merged

test(Preview): Add preview endpoint tests#21
szemyd merged 3 commits intomainfrom
feature/test-preview-endpoint

Conversation

@szemyd
Copy link
Copy Markdown
Contributor

@szemyd szemyd commented Apr 10, 2026

Summary

  • Adds tests/test_preview.py with TestPreview covering the live preview endpoint
  • Re-enables the README preview block in test_readme_block_runs (was suppressed while the endpoint was undeployed; now returns 401 as expected)

Test cases

Happy path

  • test_invalid_api_key_raises_401 — auth fires before whitelist check
  • test_ohlcv_returns_dataframe — exact whitelist params return data with OHLCV columns
  • test_l2_imbalance_returns_dataframe — l2_imbalance whitelist entry works

Structurally non-whitelisted date ranges → 400

These are parametrized cases chosen because no preview window could ever legitimately cover them — not just "not currently in the whitelist" but structurally impossible:

Case Range Reason
2.5-year span 2020-01-01 → 2022-06-01 Preview is a small sample, never multi-year
3-year span 2018-01-01 → 2021-01-01 Same
12-month recent 2025-01-01 → 2025-12-31 Preview windows are narrow historical slices
12-month (2024) 2024-01-01 → 2024-12-31 Same
6-month recent 2025-01-01 → 2025-06-30 > 3 months recent = never whitelisted

https://claude.ai/code/session_01SZBHZWVen9b3x4iNDXLWcr

claude added 3 commits April 10, 2026 09:49
…ew block

Adds TestPreview covering:
- 401 on invalid API key (auth precedes whitelist check)
- Happy path for both whitelisted metrics (ohlcv + l2_imbalance)
- Structural 400 cases for date ranges that will never be whitelisted:
  multi-year spans and recent windows wider than 3 months

Also removes the preview=True filter from test_readme_block_runs now that
the preview endpoint is live in production and returns 401 for the
placeholder key (as the test expects).

https://claude.ai/code/session_01SZBHZWVen9b3x4iNDXLWcr
…ing ones

The server clamps requests that overlap the whitelist window rather than
rejecting them — so 2025-01-01→2025-12-31 returned data (clamped to
2025-05-01→2025-05-31) instead of 400. Replace with ranges that sit
entirely outside the whitelisted window.

https://claude.ai/code/session_01SZBHZWVen9b3x4iNDXLWcr
… rejects them

The server now uses isPreviewQueryAllowed (reject) instead of clampToPreviewRange,
so requests like 2025-01-01→2025-12-31 correctly return 400 rather than being
silently clamped to the whitelist window.

https://claude.ai/code/session_01SZBHZWVen9b3x4iNDXLWcr
@szemyd szemyd merged commit 7bb916a into main Apr 10, 2026
21 of 56 checks passed
@szemyd szemyd deleted the feature/test-preview-endpoint branch April 10, 2026 11:07
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.

2 participants