[testbot] Add tests for streaming.py - #1277
Conversation
PR #1253 opened with 9 pylint errors (8x W0212 protected-access on _upload_worker_input_generator, 1x C2801 unnecessary-dunder-call) and failed ci-internal on //src/lib/data/storage/tests:test_uploading-pylint. It is not the first: #1184 needed a "fix pylint failures" follow-up and #1245 a lint-fix commit. The generator trace for run/30499270675 shows why. Of its 12 Bash calls, none contained "pylint" -- it ran `bazel test <single target>`, which runs the test but not the sibling `-pylint` target that osmo_py_test generates and that PR CI runs. Its own TodoWrite plan had no style step at all. And of its 23 Read calls, none opened TESTBOT_RULES.md, the only place that documents either the lint command or the "test PUBLIC behavior only" rule that the W0212s violate. Two fixes, both removing the need for the model to remember something: 1. TESTBOT_RULES.md now says to run `bazel test //<package>:all` instead of naming a single target. The lint sibling lives in the same package, so one command covers both and there is no second step to skip. This matches what the coverage step already tells the agent to do (`bazel coverage //src/<package>:all`). Also documents the two pylint failures generated tests actually hit. 2. The workflow now splices TESTBOT_RULES.md into the prompt instead of referencing it by path, the same way coverage targets are inlined. An instruction nothing verifies is followed only sometimes. Verified: `bazel query 'tests(//src/lib/data/storage/tests:all)'` lists test_uploading-pylint, so :all would have caught #1253 before the PR existed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Wording only, no behavior change. The rationale for the change lives in the previous commit message and PR #1276; the inline comment and prompt text only need to say what to do. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Revert the TESTBOT_RULES.md verification changes and trim the added comment and prompt wording. The remaining change is the minimum fix: the prompt carries the rules instead of referencing them by path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe change adds comprehensive ChangesStreaming test coverage
Testbot prompt assembly
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/data/storage/tests/test_streaming.py (1)
64-69: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winImplement bounded reads in
_FakeResumableStream.read.When
nis non-negative, return at mostnbytes and preserve unread bytes for subsequent reads. Add a test for partial reads.🤖 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` around lines 64 - 69, Update _FakeResumableStream.read to honor non-negative n by returning no more than n bytes while retaining any unread chunk data in _remaining for later calls; preserve draining behavior for n < 0 and keep _bytes_read accurate. Add coverage for partial reads and subsequent retrieval of the preserved bytes.
🤖 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.
Nitpick comments:
In `@src/lib/data/storage/tests/test_streaming.py`:
- Around line 64-69: Update _FakeResumableStream.read to honor non-negative n by
returning no more than n bytes while retaining any unread chunk data in
_remaining for later calls; preserve draining behavior for n < 0 and keep
_bytes_read accurate. Add coverage for partial reads and subsequent retrieval of
the preserved bytes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: af9a616d-d606-4f27-939a-7057111f4792
📒 Files selected for processing (4)
.github/workflows/testbot.yamlsrc/lib/data/storage/tests/BUILDsrc/lib/data/storage/tests/test_streaming.pysrc/scripts/testbot/TESTBOT_PROMPT.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1277 +/- ##
==========================================
+ Coverage 69.26% 69.60% +0.33%
==========================================
Files 238 238
Lines 28325 28325
Branches 4272 4272
==========================================
+ Hits 19620 19716 +96
+ Misses 7865 7765 -100
- Partials 840 844 +4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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 26 tests pass with mypy and pylint clean, and the coverage self-check reports 52/54 listed lines hit (96%).
What the 26 tests cover, all driven through the public
stream_objectentry point:_stream_response): all threeStreamOptionsarms, asserting the exactget_objectkwargs so an unranged GET can't silently replace a ranged one._seek_last_n_lines_byte_start): the offset the second ranged GET asks for on a 5-line file (18), a line reassembled across a chunk boundary (12), and a final line with no trailing newline — these are the off-by-one/deque cases flagged as the risk.last_n_lines == total_lines,last_n_lines > total_lines, and an empty object all take thebyte_start is Nonepath and issue an unranged second GET.replace/ignore/strict, newline re-termination), and theas_iofile-like path including summary-only-after-close.StreamSummary: size, line count (Nonefor byte streams), retries, and error-to-failure-string mapping.Files changed:
src/lib/data/storage/tests/test_streaming.py(new) and atest_streamingosmo_py_testentry insrc/lib/data/storage/tests/BUILD.One workflow note:
bazel coverageand the verifier both worked, but$RUNNER_TEMPexpansion was blocked by the permission layer (Contains simple_expansion) for bothecho $RUNNER_TEMPand thepython … "$RUNNER_TEMP/…"form the prompt recommends. I passed the literal/home/runner/work/_temp/...path instead. The generate prompt's step 10 may need updating, since the documented command form is currently unusable.Coverage gain on listed uncovered ranges
✅
src/lib/data/storage/streaming.py— 52/54 listed lines hit (96%)Checklist
Generated by testbot pipeline
Summary by CodeRabbit