Address market data backend review findings - #5
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
planning/MARKET_DATA_REVIEW.md:stream.pywas 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 httpxASGITransport/ FastAPITestClientrecipe suggested inMARKET_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.PriceCache.update()silently replacing an explicittimestamp=0.0withtime.time()(falsy-zero bug, dormant in production but worth closing).test_exception_resiliencenow actually injects astep()failure and asserts the simulator loop recovers, instead of just checking the task is alive.test_custom_update_intervalto remove latent CI flakiness risk.ruff format's the 3 previously-flagged test files.planning/MARKET_DATA_SUMMARY.mdand the top-levelREADME.mdto the current numbers (79 tests, 99% overall coverage).Test plan
uv run pytest -v— 79 passed, 0 faileduv run pytest --cov=app— 99% overall (stream.py: 100%, up from 33%)uv run ruff check app/ tests/— all checks passeduv run ruff format --check app/ tests/— all files formatted🤖 Generated with Claude Code