Skip to content

Make test_workflow_validation exercise the push copy loop#5151

Open
sir-sigurd wants to merge 2 commits into
masterfrom
fix-workflow-validation-mock
Open

Make test_workflow_validation exercise the push copy loop#5151
sir-sigurd wants to merge 2 commits into
masterfrom
fix-workflow-validation-mock

Conversation

@sir-sigurd

@sir-sigurd sir-sigurd commented Jul 25, 2026

Copy link
Copy Markdown
Member

Description

test_workflow_validation patched copy_file_list without a side_effect, so the mock returned a bare MagicMock, which iterates as empty. zip(entries, results) in Package._push therefore yielded nothing — the copied entry was never _set on the new package, so the push subtests have been asserting against an empty manifest ever since the test was added. Line coverage of packages.py scoped to just this test confirms it: the whole loop body never executed, and the package passed to _push_manifest had no logical keys at all. The test didn't notice because it only checked push_manifest_mock.assert_called_once() — call count, never content.

Configuring that mock alone isn't sufficient. _mock_copy_file_list reports no checksum, which leaves the entry hashless and sends _calculate_missing_hashes to S3 (UnStubbedResponseError on GetObject), so calculate_multipart_checksum needs a stub too — the same pairing test_push_selector_functions already uses.

The added assertions make the coverage self-protecting: dropping the copy_file_list side_effect now fails with KeyError: 'foo', and dropping the calculate_multipart_checksum one fails on the entry's hash — without the latter assertion that stub was dead weight, since zip(self._incomplete_entries, results) in _calculate_missing_hashes silently truncates against an empty MagicMock and leaves the entry hashless. autospec=True is what lets the mock record the package instance it was called on, since a plain MagicMock isn't a descriptor and never receives self.

This is also a prerequisite for enabling ruff's B905 (zip() without explicit strict=), which would turn the silent truncation here into a hard error.

TODO

  • Unit tests

Greptile Summary

This PR strengthens workflow-validation coverage for package pushes.

  • Exercises the copy loop by giving copy_file_list a realistic side effect.
  • Stubs checksum calculation so copied entries can complete push processing without S3 access.
  • Uses an autospecced _push_manifest mock 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

Filename Overview
api/python/tests/integration/test_packages.py Updates the workflow-validation test to exercise and verify the push copy loop; no actionable issues found.

Reviews (1): Last reviewed commit: "Make test_workflow_validation exercise t..." | Re-trigger Greptile

`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

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.60%. Comparing base (f991064) to head (dd03ac7).

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              
Flag Coverage Δ
api-python 93.22% <100.00%> (+<0.01%) ⬆️
catalog 25.19% <ø> (ø)
lambda 97.10% <ø> (ø)
py-shared 98.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
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