Skip to content

test: add offline tests for download checksum helpers - #106

Open
TejasKumat8 wants to merge 1 commit into
dbpedia:mainfrom
TejasKumat8:test/download-checksum-helpers
Open

TejasKumat8 wants to merge 1 commit into
dbpedia:mainfrom
TejasKumat8:test/download-checksum-helpers

Conversation

@TejasKumat8

@TejasKumat8 TejasKumat8 commented Oct 29, 2026 •

Copy link
Copy Markdown

Hi! This adds tests for the checksum helpers in api/download.py that --validate-checksum relies on. They didn't have tests yet: _extract_checksum_from_node, _extract_checksums_from_jsonld, _resolve_checksums_for_urls and get_expected_checksum.

The new file is tests/test_download_checksums.py, with 35 tests. The JSON-LD in the tests follows the shape of real Part nodes on databus.dbpedia.org (sha256sum, file, @id). fetch_databus_jsonld is mocked, so nothing hits the network.

As a quick sanity check, I temporarily broke the SHA-256 regex locally, and 19 of the new tests failed while the existing suite still passed.

No source changes, so I didn't bump the version. Happy to adjust anything if useful.

Related Issues
None directly. Addresses the low test coverage mentioned in the README.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functi
  • This change requires a documentation update
  • Housekeep

Checklist:

  • My code follows the ruff code style of this project.
  • I have pewn code
  • I have commented my code, particularly in
    hard-to-underst
  • I have made corresponding changes to the documentation
    (if applicable)
  • I have added tests that prove my fix is effective or
    that my feature
  • New and existing unit tests pass locally with my
    changes
    • pytest: 233 passed, 3 skipped
    • `rufflock): no linting errors

Summary by CodeRabbit

  • Tests
    • Expanded offline test coverage for checksum handling, including metadata extraction, URL matching, multiple file parts, malformed values, and fetch failures.
    • Added checks for missing checksums, filtering results to requested URLs, and reusing version metadata fetches.

Cover _extract_checksum_from_node, _extract_checksums_from_jsonld,
_resolve_checksums_for_urls and get_expected_checksum, which back
--validate-checksum and had no tests. The JSON-LD fixtures follow the
real Part node shape (sha256sum, file, @id) and the network is mocked.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4993a9b9-6d83-40c7-a44a-b6bcb4f465ba
Commits

Reviewing files that changed from the base of the PR and between 0dc1982 and 2ee1fef.

Files selected for processing: 1
  • tests/test_download_checksums.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The pull request adds offline tests for checksum extraction from metadata, JSON-LD checksum mappings, URL-based resolution, and expected-checksum lookup.

Changes: Checksum helper tests

Layer / File(s) Summary
Checksum extraction and JSON-LD mappings
tests/test_download_checksums.py
Adds fixtures and tests for accepted checksum keys and value shapes, invalid values, and mappings from JSON-LD metadata to file URLs and node IDs.
URL-based checksum resolution
tests/test_download_checksums.py
Tests version fetching, URL filtering, HTTP-to-HTTPS metadata matching, missing checksums, and fetch-error handling.

Priority: Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 2ee1f

The offline checksum-helper tests present no identified merge-blocking risk. Merge after normal checks pass.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the test scope, mocked network behavior, related issue context, and reported test results. However, the Type of change section is truncated, several checklist items are corrup… Restore the complete description template. Correct the Type of change options and checklist text. State the exact lint command and confirm its result. Keep the test and validation details already provided.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the addition of offline tests for download checksum helpers, which matches the main change.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the test scope, mocked network behavior, related issue context, and reported test results. However, the Type of change section is truncated, several checklist items are corrupted or incomplete, and the lint command is unclear.

Resolution

Restore the complete description template. Correct the Type of change options and checklist text. State the exact lint command and confirm its result. Keep the test and validation details already provided.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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