Make test_workflow_validation exercise the push copy loop#5151
Open
sir-sigurd wants to merge 2 commits into
Open
Make test_workflow_validation exercise the push copy loop#5151sir-sigurd wants to merge 2 commits into
sir-sigurd wants to merge 2 commits into
Conversation
`copy_file_list` was patched without a `side_effect`, so it returned a bare MagicMock, which iterates as empty. `zip(entries, results)` in `_push` thus yielded nothing: the copied entry was never `_set` on the new package, and the push subtests asserted against a silently empty manifest. Configuring it also requires stubbing `calculate_multipart_checksum`, since `_mock_copy_file_list` reports no checksum and `_calculate_missing_hashes` would otherwise reach for S3. The new physical-key assertion keeps the loop from going uncovered again unnoticed; `autospec=True` makes the mock record the package it was called on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5151 +/- ##
==========================================
+ Coverage 49.58% 49.60% +0.01%
==========================================
Files 844 844
Lines 34461 34472 +11
Branches 5830 5830
==========================================
+ Hits 17088 17099 +11
Misses 15489 15489
Partials 1884 1884
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Without this the `calculate_multipart_checksum` stub was dead weight: dropping its `side_effect` left `zip(self._incomplete_entries, results)` in `_calculate_missing_hashes` iterating an empty MagicMock, so the pushed entry kept `hash is None` and the test still passed. Use the file's `"a" * 64` convention for the stubbed value. Co-Authored-By: Claude Opus 5 (1M context) <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.
Description
test_workflow_validationpatchedcopy_file_listwithout aside_effect, so the mock returned a bareMagicMock, which iterates as empty.zip(entries, results)inPackage._pushtherefore yielded nothing — the copied entry was never_seton the new package, so thepushsubtests have been asserting against an empty manifest ever since the test was added. Line coverage ofpackages.pyscoped to just this test confirms it: the whole loop body never executed, and the package passed to_push_manifesthad no logical keys at all. The test didn't notice because it only checkedpush_manifest_mock.assert_called_once()— call count, never content.Configuring that mock alone isn't sufficient.
_mock_copy_file_listreports no checksum, which leaves the entry hashless and sends_calculate_missing_hashesto S3 (UnStubbedResponseErroronGetObject), socalculate_multipart_checksumneeds a stub too — the same pairingtest_push_selector_functionsalready uses.The added assertions make the coverage self-protecting: dropping the
copy_file_listside_effectnow fails withKeyError: 'foo', and dropping thecalculate_multipart_checksumone fails on the entry'shash— without the latter assertion that stub was dead weight, sincezip(self._incomplete_entries, results)in_calculate_missing_hashessilently truncates against an empty MagicMock and leaves the entry hashless.autospec=Trueis what lets the mock record the package instance it was called on, since a plainMagicMockisn't a descriptor and never receivesself.This is also a prerequisite for enabling ruff's
B905(zip()without explicitstrict=), which would turn the silent truncation here into a hard error.TODO
Greptile Summary
This PR strengthens workflow-validation coverage for package pushes.
copy_file_lista realistic side effect._push_manifestmock to inspect the package instance and verify the copied entry’s physical key.Confidence Score: 5/5
The PR appears safe to merge with no actionable defects identified.
The new mock contracts match the production call shapes, the autospecced method records the intended package instance, and the added assertion verifies that the copied entry reaches the pushed manifest.
Important Files Changed
Reviews (1): Last reviewed commit: "Make test_workflow_validation exercise t..." | Re-trigger Greptile