Bugzilla – Attachment 128762 Details for
Bug 29018
Deleting patrons from REST API doesn't do any checks or move to deletedborrowers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29018: Regression tests
Bug-29018-Regression-tests.patch (text/plain), 3.28 KB, created by
Tomás Cohen Arazi
on 2021-12-20 15:19:12 UTC
(
hide
)
Description:
Bug 29018: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2021-12-20 15:19:12 UTC
Size:
3.28 KB
patch
obsolete
>From 42803255e10d784784487007163d470afa2045d8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Dec 2021 12:05:28 -0300 >Subject: [PATCH] Bug 29018: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/patrons.t | 40 ++++++++++++++++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index c3726f54bb..1081f0e086 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -31,6 +31,7 @@ use Koha::Database; > use Koha::DateUtils qw(dt_from_string output_pref); > use Koha::Exceptions::Patron; > use Koha::Exceptions::Patron::Attribute; >+use Koha::Old::Patrons; > use Koha::Patron::Attributes; > use Koha::Patron::Debarments qw( AddDebarment ); > >@@ -640,7 +641,7 @@ subtest 'delete() tests' => sub { > $schema->storage->txn_rollback; > > subtest 'librarian access test' => sub { >- plan tests => 8; >+ plan tests => 18; > > $schema->storage->txn_begin; > >@@ -665,11 +666,48 @@ subtest 'delete() tests' => sub { > ->status_is(403, 'Anonymous patron cannot be deleted') > ->json_is( { error => 'Anonymous patron cannot be deleted' } ); > >+ t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' ); >+ >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ my $debit = $patron->account->add_debit({ amount => 10, interface => 'intranet', type => 'MANUAL' }); >+ my $guarantee = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ $guarantee->add_guarantor({ guarantor_id => $patron->id, relationship => 'parent' }); >+ >+ $t->delete_ok("//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber) >+ ->status_is(409, 'Patron with checkouts cannot be deleted') >+ ->json_is( { error => 'Pending checkouts prevent deletion' } ); >+ >+ # Make sure it has no pending checkouts >+ $checkout->delete; >+ >+ $t->delete_ok("//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber) >+ ->status_is(409, 'Patron with debt cannot be deleted') >+ ->json_is( { error => 'Pending debts prevent deletion' } ); >+ >+ # Make sure it has no debt >+ $patron->account->pay({ amount => 10, debits => [ $debit ] }); >+ >+ $t->delete_ok("//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber) >+ ->status_is(409, 'Patron with guarantees cannot be deleted') >+ ->json_is( { error => 'Patron is a guarantor and it prevents deletion' } ); >+ >+ # Remove guarantee >+ $patron->guarantee_relationships->delete; >+ > t::lib::Mocks::mock_preference('AnonymousPatron', 0); # back to default > $t->delete_ok("//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber) > ->status_is(204, 'SWAGGER3.2.4') > ->content_is('', 'SWAGGER3.3.4'); > >+ my $deleted_patrons = Koha::Old::Patrons->search({ borrowernumber => $patron->borrowernumber }); >+ is( $deleted_patrons->count, 1, 'The patron has been moved to the vault' ); >+ > $schema->storage->txn_rollback; > }; > }; >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29018
:
128762
|
128763
|
128812
|
128813
|
128959
|
128960
|
129282
|
129283