Skip to content

test: add offline tests for delete resource, artifact and dispatch - #128

Open
TejasKumat8 wants to merge 1 commit into
dbpedia:mainfrom
TejasKumat8:test/delete-resource-dispatch
Open

TejasKumat8 wants to merge 1 commit into
dbpedia:mainfrom
TejasKumat8:test/delete-resource-dispatch

Conversation

@TejasKumat8

@TejasKumat8 TejasKumat8 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Description

Adds tests/test_delete_resource.py, offline tests for the parts of api/delete.py that had no tests yet. Only this one file is added, no source changes.

delete.py coverage was 52%. With these tests it is 100%. DeleteQueue, _confirm_delete and _delete_group were already covered.

What is tested:

  • _delete_resource: the DELETE request and its X-API-KEY header, 200/204 recorded in the manifest, an error status raises, dry run sends nothing and records dry_run, a queue only queues, a missing key raises, and the skip / cancel / confirm answers
  • _delete_artifact: one version (dict), several versions (list), no versions, versions without @id. In all cases versions are deleted first, then the artifact
  • delete(): collection, version, artifact and group URIs go to the right helper, file and account URIs do nothing, and queued deletes run deepest first

requests.delete and fetch_databus_jsonld are monkeypatched, so nothing touches the network.

I also broke delete.py on purpose in 7 ways (e.g. dropping 204, ignoring the queue, never running the queue) and each one made at least one new test fail.

Related Issues
None.

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 functionality to change)
  • This change requires a documentation update
  • Housekeeping

Checklist:

  • My code follows the ruff code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
    • pytest - 300 passed, 3 skipped
    • ruff check (0.5.7) - no linting errors

Happy to change anything.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds offline tests for resource deletion requests, artifact version deletion, and URI-based deletion dispatch. The tests use fakes to record HTTP DELETE calls and stub JSON-LD fetching.

Changes: Deletion Test Coverage

Layer / File(s) Summary
Resource deletion request tests
tests/test_delete_resource.py
Adds test fakes and asserts request details, response handling, dry-run behavior, queueing, API-key checks, and confirmation outcomes.
Artifact deletion and URI dispatch tests
tests/test_delete_resource.py
Asserts version deletion order, artifact deletion behavior, URI dispatch targets, unsupported URI handling, and queued artifact deletion order.

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

Change: Other

Suggested reviewers: integer-ctrl

Merge Risk: Minimal · up to 2a148

This change adds tests for deletion behavior and does not alter production code, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change accurately: it adds offline tests for the delete resource, artifact, and dispatch logic in api/delete.py. The changeset adds only tests/test_delete_resource.py, which covers…
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.
Description check Passed The description is well filled in. It explains what the PR adds (tests/test_delete_resource.py, no source changes), lists the covered behaviours, reports coverage rising from 52% to 100%, and notes th…
Full details: Title check

Explanation

The title names the change accurately: it adds offline tests for the delete resource, artifact, and dispatch logic in api/delete.py. The changeset adds only tests/test_delete_resource.py, which covers those three areas. The title is specific and matches the main change, so it passes.

Full details: Description check

Explanation

The description is well filled in. It explains what the PR adds (tests/test_delete_resource.py, no source changes), lists the covered behaviours, reports coverage rising from 52% to 100%, and notes the mocking approach and mutation checks. It sets the type of change to Housekeeping and ticks the ruff, self-review, and test checkboxes with reported results (pytest 300 passed, 3 skipped; ruff check clean). Related Issues says None. Two template items are not ticked: the commenting checkbox and the documentation checkbox. Both are reasonable to leave unchecked for a test-only change. The description is mostly complete, so the check passes.

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

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: 408e8d62-d8f3-4921-8661-45a3da937853
Commits

Reviewing files that changed from the base of the PR and between b35bd2c and 2a14880.

Files selected for processing: 1

  • tests/test_delete_resource.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.

This branch has not been deployed

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