Skip to content

Refactoring verification module#60

Open
codedbyishika wants to merge 20 commits into
mainfrom
refactoring_verify_downloads
Open

Refactoring verification module#60
codedbyishika wants to merge 20 commits into
mainfrom
refactoring_verify_downloads

Conversation

@codedbyishika

@codedbyishika codedbyishika commented Jun 5, 2026

Copy link
Copy Markdown
  • Refactor download verification module: move remaining post-download verification functions from __main__.py to buddy_check.py
  • Change imports
  • Edit AGENTS.md
  • Include unit tests

@codedbyishika codedbyishika self-assigned this Jun 5, 2026
@codedbyishika codedbyishika requested a review from egrace479 June 5, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and verify_downloads() from __main__.py to buddy_check.py.
  • Updated tests to patch get_checksums / BuddyCheck in the new module location and added a new test suite for verification helpers.
  • Updated AGENTS.md to 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.

Comment thread src/cautiousrobot/buddy_check.py Outdated
Comment thread src/cautiousrobot/buddy_check.py Outdated
Comment thread tests/test_verify_downloads.py Outdated
Comment thread src/cautiousrobot/buddy_check.py Outdated
Comment thread src/cautiousrobot/buddy_check.py Outdated
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
Comment thread src/cautiousrobot/buddy_check.py Outdated
egrace479 and others added 2 commits June 9, 2026 14:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread tests/test_verify_downloads.py

@egrace479 egrace479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes on the test case setups.

Comment thread tests/test_verify_downloads.py Outdated
Comment thread tests/test_verify_downloads.py
Comment thread tests/test_verify_downloads.py Outdated
Comment thread tests/test_verify_downloads.py
Comment thread tests/test_verify_downloads.py Outdated
codedbyishika and others added 3 commits June 10, 2026 17:18
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 egrace479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add a test that calls verify_downloads with filename_col != "filename" to ensure something like this is caught in the future.

Comment thread src/cautiousrobot/buddy_check.py Outdated
codedbyishika and others added 3 commits June 11, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread tests/test_verify_downloads.py
Comment thread tests/test_verify_downloads.py Outdated
codedbyishika and others added 2 commits June 11, 2026 17:19
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>
@egrace479 egrace479 requested a review from thompsonmj June 16, 2026 15:11
Comment thread tests/test_verify_downloads.py Outdated
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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed redundant tests

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tests/test_verify_downloads.py Outdated
)

@patch('cautiousrobot.buddy_check.get_checksums')
def test_process_checksums_different_algorithm(self, mock_get_checksums):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@codedbyishika codedbyishika Jul 7, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed test temporarily and will be addressed in the new issue

Comment thread tests/test_verify_downloads.py Outdated
shutil.rmtree(self.temp_dir)

@patch('cautiousrobot.buddy_check.get_checksums')
def test_process_checksums_mismatched_counts(self, mock_get_checksums):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should be added to the TestProcessChecksums class.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the test to TestProcessChecksums

- Update docstrings from main branch
- Update tests according to comments
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.

Move download verification functions into buddy_check.py

4 participants