Skip to content

Address market data backend review findings - #5

Merged
raunaksachdev merged 1 commit into
mainfrom
fix/market-data-review
Aug 25, 2026
Merged

Address market data backend review findings#5
raunaksachdev merged 1 commit into
mainfrom
fix/market-data-review

Conversation

@raunaksachdev

Copy link
Copy Markdown
Owner

Summary

  • Closes the one open coverage gap from planning/MARKET_DATA_REVIEW.md: stream.py was untested (0% on the SSE generator/route); now at 100% via generator-level and route-handler-level tests (backend/tests/market/test_stream.py). Note: the httpx ASGITransport / FastAPI TestClient recipe suggested in MARKET_DATA_DESIGN.md §12.4 deadlocks against _generate_events's infinite loop with the currently installed dependency versions (both buffer the entire ASGI response before returning control), so these tests drive the real generator and route coroutine directly instead.
  • Fixes PriceCache.update() silently replacing an explicit timestamp=0.0 with time.time() (falsy-zero bug, dormant in production but worth closing).
  • test_exception_resilience now actually injects a step() failure and asserts the simulator loop recovers, instead of just checking the task is alive.
  • Widens the timing margin in test_custom_update_interval to remove latent CI flakiness risk.
  • ruff format's the 3 previously-flagged test files.
  • Updates the stale coverage figures in planning/MARKET_DATA_SUMMARY.md and the top-level README.md to the current numbers (79 tests, 99% overall coverage).

Test plan

  • uv run pytest -v — 79 passed, 0 failed
  • uv run pytest --cov=app — 99% overall (stream.py: 100%, up from 33%)
  • uv run ruff check app/ tests/ — all checks passed
  • uv run ruff format --check app/ tests/ — all files formatted

🤖 Generated with Claude Code

… fix flaky/weak tests, fix falsy-timestamp bug

- Add ASGI-route-level and generator-level tests for stream.py (0% -> 100%
  coverage on that module). Note: the httpx ASGITransport / FastAPI
  TestClient recipe suggested in MARKET_DATA_DESIGN.md deadlocks against
  _generate_events's infinite loop in the installed dependency versions
  (both buffer the full response before returning), so the tests instead
  drive the real generator and route handler coroutine directly.
- Fix PriceCache.update() treating an explicit timestamp=0.0 as falsy and
  silently replacing it with time.time().
- test_exception_resilience now actually injects a step() failure and
  asserts the loop recovers, instead of just asserting the task is alive.
- Widen the timing margin in test_custom_update_interval to remove latent
  flakiness risk.
- ruff format the 3 flagged test files.
- Add httpx as a dev dependency (needed for the new stream tests).
- Update the stale coverage figures in planning/MARKET_DATA_SUMMARY.md and
  README.md to the current 79 tests / 99% overall.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@raunaksachdev
raunaksachdev merged commit d9bfd3a into main Aug 25, 2026
1 check passed
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.

1 participant