Refactoring verification module#60
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the post-download verification workflow by moving checksum generation and download verification helpers out of __main__.py into buddy_check.py, updating references/documentation accordingly, and adding unit tests to cover the moved functionality.
Changes:
- Moved
process_checksums()andverify_downloads()from__main__.pytobuddy_check.py. - Updated tests to patch
get_checksums/BuddyCheckin the new module location and added a new test suite for verification helpers. - Updated
AGENTS.mdto reflect the new module responsibilities and documented the new helper functions.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_verify_downloads.py |
Adds unit tests for process_checksums() and verify_downloads() after refactor. |
tests/test_download_images.py |
Updates patch targets to reflect moved checksum/verification code. |
src/cautiousrobot/buddy_check.py |
Adds process_checksums() and verify_downloads() and imports get_checksums. |
src/cautiousrobot/__main__.py |
Removes inlined checksum/verification helpers; imports them from buddy_check.py. |
AGENTS.md |
Updates architecture docs to reflect refactor and new helper functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This reverts commit 1a75a3a.
egrace479
left a comment
There was a problem hiding this comment.
Some notes on the test case setups.
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
- change "md5" to "hash" - specify error printouts - remove unused test
egrace479
left a comment
There was a problem hiding this comment.
We should probably add a test that calls verify_downloads with filename_col != "filename" to ensure something like this is caught in the future.
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| self.assertEqual(call_kwargs["source_validation_col"], "hash") | ||
|
|
||
| @patch('cautiousrobot.buddy_check.BuddyCheck') | ||
| def test_verify_downloads_calls_buddy_check_with_correct_params(self, mock_buddy_check_class): |
There was a problem hiding this comment.
Seems redundant to test_verify_downloads_uses_correct_algorithm() and test_verify_downloads_with_custom_filename_col(). Would recommend removing test_verify_downloads_calls_buddy_check_with_correct_params().
There was a problem hiding this comment.
Retrieved test_verify_downloads_uses_correct_algorithm and test_verify_downloads_with_custom_filename_col tests and removed test_verify_downloads_calls_buddy_check_with_correct_params
| ) | ||
|
|
||
| @patch('cautiousrobot.buddy_check.get_checksums') | ||
| def test_process_checksums_different_algorithm(self, mock_get_checksums): |
There was a problem hiding this comment.
I think this would work better as an integration test on the CLI -a input (actually execute a checksum) rather than a mock. Here, it does not really test a different checksum algorithm. Going through a real #sum-buddy or BuddyCheck could actually break on non-md5, which would make a more valuable test.
For this PR, I would suggest removing this unit test, then we can revisit the checksum algorithm contract that passes through the code and make corresponding integration tests there.
There was a problem hiding this comment.
Removed test temporarily and will be addressed in the new issue
| shutil.rmtree(self.temp_dir) | ||
|
|
||
| @patch('cautiousrobot.buddy_check.get_checksums') | ||
| def test_process_checksums_mismatched_counts(self, mock_get_checksums): |
There was a problem hiding this comment.
This test should be added to the TestProcessChecksums class.
There was a problem hiding this comment.
Moved the test to TestProcessChecksums
- Update docstrings from main branch - Update tests according to comments
__main__.pytobuddy_check.py