[testbot] Add tests for streaming.py - #1280
Conversation
📝 WalkthroughWalkthroughThe change adds a Bazel target and comprehensive unit tests for storage streaming. Tests cover byte, decoded-line, offset, last-N-lines, and file-like modes, including summaries, errors, client lifecycle, boundaries, and option validation. ChangesStorage streaming test coverage
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/lib/data/storage/tests/test_streaming.py (1)
108-108: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the generic result types explicit.
client.APIResponse,Iterator, andListomit their item types. This prevents type checking from detecting fixture and stream-output mismatches. Useclient.APIResponse[client.GetObjectResponse]and aTypeVarfor_drain.As per coding guidelines, use type annotations where they improve clarity. As per path instructions, keep strict type annotations.
Also applies to: 157-158
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/data/storage/tests/test_streaming.py` at line 108, Make the generic annotations explicit in the affected streaming test helpers: change the API response annotation to client.APIResponse[client.GetObjectResponse], and update _drain to use a TypeVar so its Iterator and List item types are preserved. Apply the same explicit item typing to the related annotations at the additionally referenced lines, keeping strict type checking throughout.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/data/storage/tests/test_streaming.py`:
- Around line 542-543: Extend the test around stream_io.close() to assert that
stream_io.summary is not None after closing, while preserving the existing
assertion that it starts as None.
---
Nitpick comments:
In `@src/lib/data/storage/tests/test_streaming.py`:
- Line 108: Make the generic annotations explicit in the affected streaming test
helpers: change the API response annotation to
client.APIResponse[client.GetObjectResponse], and update _drain to use a TypeVar
so its Iterator and List item types are preserved. Apply the same explicit item
typing to the related annotations at the additionally referenced lines, keeping
strict type checking throughout.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e373423f-8dcd-40b1-b610-1b51199c192e
📒 Files selected for processing (2)
src/lib/data/storage/tests/BUILDsrc/lib/data/storage/tests/test_streaming.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1280 +/- ##
==========================================
+ Coverage 70.16% 70.51% +0.34%
==========================================
Files 238 238
Lines 28325 28325
Branches 4272 4272
==========================================
+ Hits 19873 19972 +99
+ Misses 7640 7538 -102
- Partials 812 815 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
* testbot: let Slack unfurl the PR link into a GitHub card The review request posted no preview card. Two reasons: Slack unfurls links from a message's `text`, not from inside Block Kit blocks, and messages posted by a bot do not unfurl unless unfurl_links is set. The blocks array duplicated `text` verbatim, so dropping it costs nothing. With unfurling enabled the official GitHub Slack app -- already installed and unfurling PR links in #osmo-code-reviews -- renders the card under the message. No link_shared handler needed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * testbot: target 3 files per run instead of 1 Every recent testbot PR covered exactly one source file (#1273, #1278, #1280, #1283, #1288 — the second changed file is just the BUILD entry). Raise max_targets 1 -> 3. max_turns goes 200 -> 400 to match: the generator runs the full read/write/verify/coverage loop per target, and a single target has already hit the limit once (runs/26536045087, 101/100). max_uncovered stays at 500. It is a per-target cap, and recent targets carried 35-231 uncovered lines, so it is not the binding constraint -- max_targets is. Schedule and timeout are unchanged. Also refresh the README table, which still documented max_turns=100 and timeout_minutes=30 against the workflow's 200 and 60. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * testbot: drop the per-range checklist from the PR body The coverage report listed every range the generator targeted, one bullet each with a ✅/❌ and a hit count. On #1253 that was 35 bullets, all ✅, under a summary line that already said 61/61. It pushed the useful content off-screen and nobody reads it. Keep the per-target summary line and name only the ranges still missing coverage, capped at MAX_REPORTED_RANGES with an "and N more" tail. The JSON sidecar still carries the full per-range detail for the generator's self-iteration loop, which is what actually consumes it.
Summary
AI-generated tests targeting file(s) with low coverage.
Issue - None
Targets selected
src/lib/data/storage/streaming.pyWhy this file was targeted
src/lib/data/storage/streaming.py— 44.9% coverage, 54 uncovered lines.Generator summary
All 11 targets in the package pass.
What was added
src/lib/data/storage/tests/test_streaming.py(36 tests, wired via a newosmo_py_test(name = "test_streaming")insrc/lib/data/storage/tests/BUILD). Tests go through the publicstream_objectAPI only, backed by an in-memoryResumableStream/ fakeStorageClient/ realCacheableClientProvider, so the provider lifecycle is exercised rather than mocked out.Coverage by area:
_stream_response, lines 304–332): asserts the exactget_object(bucket, key, offset, length)calls issued forFullStream,OffsetStream(with and without length), andLastNLinesStream. Theassert_neverguard at 328/332 is reached by injecting an unrecognized option, verifying it fails loudly instead of silently streaming.n=2of 4 lines seeks to byte 12;n == line count,n > line count, and an empty object all fall back to a full second fetch (offsetNone) instead of raisingIndexError; an unterminated final line seeks to byte 6 ofalpha\nbeta\ngamma.replace/ignore/stricterror strategies), andas_io=Truefull and partial reads, includingsummary is Nonebefore close and the last-N-lines offset applied through the file-like path.StreamSummaryfidelity:size,lines,retries, andfailuresasserted against the underlying API context.Verification:
bazel testpasses, mypy clean, pylint 10.00/10, andverify_coverage.pyreportshit_fraction: 1.0with an emptystill_uncovered_ranges.Coverage gain on listed uncovered ranges
✅
src/lib/data/storage/streaming.py— 54/54 listed lines hit (100%)Checklist
Generated by testbot pipeline
Summary by CodeRabbit