Requests to cancel a hold done through ILS-DI CancelHold method do not check same conditions as cancellation done through the OPAC interface. Here are the conditions (extract from C4/Reserves.pm) : Returns 1 if reserve can be cancelled by user from OPAC. First check if reserve belongs to user, next checks if reserve is not in transfer or waiting status
Created attachment 85413 [details] [review] Bug 22379 : Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this.
Created attachment 85414 [details] [review] Bug 22379 : Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this. -------------------------------- Test plan (before patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "RecordNotFound" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -------------------------------- Test plan (after patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds.
Created attachment 94387 [details] [review] Bug 22379 : Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this. -------------------------------- Test plan (before patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "RecordNotFound" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -------------------------------- Test plan (after patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Unit tests please
Created attachment 97959 [details] [review] Bug 22379: Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this. -------------------------------- Test plan (before patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "RecordNotFound" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -------------------------------- Test plan (after patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Created attachment 97960 [details] [review] Bug 22379: Unit tests for CancelHold service
I'm happy to test if you could provide some example URLs for ILS-DI requests and the required parameters. Notes: - The patch still applies - Tests don't pass: root@722db1e0af2e:koha(bz22379)$ prove t/db_dependent/ILSDI_Services.t t/db_dependent/ILSDI_Services.t .. 6/10 Use of uninitialized value $charge in numeric gt (>) at /kohadevbox/koha/C4/Circulation.pm line 2991. t/db_dependent/ILSDI_Services.t .. 8/10 # No tests run! t/db_dependent/ILSDI_Services.t .. 9/10 # Failed test 'No tests run for subtest "CancelHold"' # at t/db_dependent/ILSDI_Services.t line 698. Can't use string ("Su0VSFAs") as a HASH ref while "strict refs" in use at /kohadevbox/koha/C4/Reserves.pm line 175. # Looks like your test exited with 255 just after 9. t/db_dependent/ILSDI_Services.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 2/10 subtests Test Summary Report ------------------- t/db_dependent/ILSDI_Services.t (Wstat: 65280 Tests: 9 Failed: 1) Failed test: 9 Non-zero exit status: 255 Parse errors: Bad plan. You planned 10 tests but ran 9. Files=1, Tests=9, 14 wallclock secs ( 0.04 usr 0.00 sys + 11.33 cusr 1.57 csys = 12.94 CPU) Result: FAIL
Created attachment 125230 [details] [review] Bug 22379: Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this. -------------------------------- Test plan (before patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "RecordNotFound" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -------------------------------- Test plan (after patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Created attachment 125231 [details] [review] Bug 22379: Unit tests for CancelHold service
Hello, I've rebased and reuploaded the patches. I also have tests failing but they seem to fail also on master : <pre> # Failed test 'Record hold, Item cannot be transferred' # at t/db_dependent/ILSDI_Services.t line 558. # got: undef # expected: 'cannotBeTransferred' </pre> Hope this will pass QA now! Arthur
Created attachment 125232 [details] [review] Bug 22379: Unit tests for CancelHold service
Created attachment 133903 [details] [review] Bug 22379: Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this. -------------------------------- Test plan (before patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "RecordNotFound" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -------------------------------- Test plan (after patch) : -Put a reserve for a borrower -Try to cancel the reserve providing another borrowernumber as argument -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Try to cancel the reserve providing the borrowernumber the reserve is for. -> Should succeed, reply with "Canceled" -> Reserve do not show up in the list of holds for the borrower -Put a new reserve with a pickup branch != from the homebranch -Transfer the item to the pickup branch (reserve status = Transit) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. -Checkout the reserved item in the pickup branch (reserve status = Waiting) -Try to cancel the reserve (with proper borrowernumber) -> Should fail and reply "BorrowerCannotCancelHold" -> Reserve still appears in the list of holds. Signed-off-by: Laurence Rault <laurence.rault@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 133904 [details] [review] Bug 22379: Unit tests for CancelHold service Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Nice one Arthur, great to see these getting some love All working, Unit tests reads well and passes.. QA script happy PQA
Pushed to master for 22.05, thanks to everybody involved [U+1F984]
Pushed to 21.11.x for 21.11.06
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.
API code correction, no documentation change required.