Bug 39869 - Club holds API missing tests
Summary: Club holds API missing tests
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 25787
Blocks:
  Show dependency treegraph
 
Reported: 2025-05-09 13:55 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-05-12 16:08 UTC (History)
1 user (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 39869: Add more tests for the club holds endpoint (10.54 KB, patch)
2025-05-09 14:00 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2025-05-09 13:55:48 UTC
The introduction of `Test::NoWarnings` (bug 38944) allowed us to detect these tests do not cover all the behavior: when the database makes `Can*BeReserved` not return `status => OK` the tests pass (because the endpoint is designed to place the hold regardless, but a warning is printed in the logs.

This behavior is not tested.

The tests should:

* Cover the item-level holds case
* Not depend on existing data/circulation rules on the DB
* Tests this `warn` behavior correctly
Comment 1 Tomás Cohen Arazi (tcohen) 2025-05-09 14:00:32 UTC
Created attachment 182177 [details] [review]
Bug 39869: Add more tests for the club holds endpoint

This patch does:

* Mock `CanItemBeReserved` and `CanBookBeReserved` to better control the
  test scenario and make it agnostic from existing data.
* Adds tests for the item-level group holds use case
* Adds tests for the warnings printed when placing the hold should not
  be possible

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/clubs_holds.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>