Skip to content

Comments

Add admin endpoint to queue collection import on demand (PP-364)#3069

Open
jonathangreen wants to merge 5 commits intomainfrom
feature/collection-import-ui
Open

Add admin endpoint to queue collection import on demand (PP-364)#3069
jonathangreen wants to merge 5 commits intomainfrom
feature/collection-import-ui

Conversation

@jonathangreen
Copy link
Member

Description

  • Add POST /admin/collection/<id>/import endpoint allowing system admins to trigger a collection import on demand, with optional force parameter
  • Introduce a SupportsImport ABC mixin to explicitly mark circulation APIs that support collection import
  • Add protocol_details to BaseCirculationAPI exposing supports_import to the admin UI so it can show/hide the import button per protocol
  • Add IMPORT_NOT_SUPPORTED problem detail for protocols that don't support import

Motivation and Context

The admin UI needs to know which collection protocols support import and needs an endpoint to trigger imports. The SupportsImport mixin follows the existing HasSelfTests pattern in the codebase, making import capability explicit via issubclass checks rather than relying on try/except NotImplementedError.

How Has This Been Tested?

  • Added tests for process_import covering: auth requirements, missing service, marked-for-deletion collections, unknown protocols, unsupported protocols, success, and force flag
  • Added route tests for the new /admin/collection/<id>/import endpoint including invalid collection ID handling
  • Added test_protocol_details_supports_import verifying detection for both supported and unsupported protocols
  • Type checked all modified files with mypy

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Add a POST /admin/collection/<id>/import endpoint that allows admins to
manually trigger a collection import task. The endpoint validates admin
permissions, checks that the collection exists and is not marked for
deletion, and queues the import task via Celery.

Also adds a `supports_import` flag to protocol details so the admin UI
can determine which collections support import, and an
IMPORT_NOT_SUPPORTED problem detail for unsupported protocols.
The fragile __mro__ walk in protocol_details and try/except
NotImplementedError pattern in the controller are replaced with
a SupportsImport ABC mixin and issubclass checks, following the
existing HasSelfTests mixin precedent.
OverdriveAPI does not implement SupportsImport, so process_post
skips the import step entirely. Remove the now-unnecessary mocks
and assertions.
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.18%. Comparing base (41cda95) to head (67d4b29).

Files with missing lines Patch % Lines
...anager/api/admin/controller/collection_settings.py 90.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3069   +/-   ##
=======================================
  Coverage   93.18%   93.18%           
=======================================
  Files         489      489           
  Lines       44942    44978   +36     
  Branches     6191     6197    +6     
=======================================
+ Hits        41879    41913   +34     
- Misses       1986     1987    +1     
- Partials     1077     1078    +1     

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant