Bugzilla – Attachment 152904 Details for
Bug 33573
Add public endpoint for cancelling holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33573: Unit tests
Bug-33573-Unit-tests.patch (text/plain), 3.54 KB, created by
Kyle M Hall (khall)
on 2023-06-30 13:06:41 UTC
(
hide
)
Description:
Bug 33573: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-06-30 13:06:41 UTC
Size:
3.54 KB
patch
obsolete
>From e7e431343f819f1e3167c5e25ed357a2909b208e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 7 Jun 2023 10:41:53 -0300 >Subject: [PATCH] Bug 33573: Unit tests > >Signed-off-by: Sam Lau <samalau@gmail.com> >Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >--- > t/db_dependent/api/v1/patrons_holds.t | 80 ++++++++++++++++++++++++++- > 1 file changed, 79 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/patrons_holds.t b/t/db_dependent/api/v1/patrons_holds.t >index 523963b81f..98cffc375b 100755 >--- a/t/db_dependent/api/v1/patrons_holds.t >+++ b/t/db_dependent/api/v1/patrons_holds.t >@@ -17,7 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; >+use Test::MockModule; > use Test::Mojo; > > use t::lib::TestBuilder; >@@ -68,3 +69,80 @@ subtest 'list() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'delete_public() tests' => sub { >+ >+ plan tests => 13; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 }, >+ } >+ ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ >+ my $hold_to_delete = $builder->build_object( { class => 'Koha::Holds' } ); >+ my $deleted_hold_id = $hold_to_delete->id; >+ $hold_to_delete->delete; >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/public/patrons/" . $patron->id . '/holds/' . $deleted_hold_id ) >+ ->status_is(404); >+ >+ my $another_user_hold = $builder->build_object( { class => 'Koha::Holds' } ); >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/public/patrons/" . $patron->id . '/holds/' . $another_user_hold->id ) >+ ->status_is( 404, 'Invalid patron_id and hold_id combination yields 404' ); >+ >+ my $non_waiting_hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ found => undef, >+ itemnumber => undef >+ } >+ } >+ ); >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/public/patrons/" . $patron->id . '/holds/' . $non_waiting_hold->id ) >+ ->status_is( 204, 'SWAGGER3.2.4' )->content_is( '', 'SWAGGER3.3.4' ); >+ >+ my $cancellation_requestable; >+ >+ my $hold_mock = Test::MockModule->new('Koha::Hold'); >+ $hold_mock->mock( 'cancellation_requestable_from_opac', sub { return $cancellation_requestable; } ); >+ >+ my $item = $builder->build_sample_item; >+ my $waiting_hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ found => 'W', >+ itemnumber => $item->id, >+ } >+ } >+ ); >+ >+ $cancellation_requestable = 0; >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/public/patrons/" . $patron->id . '/holds/' . $waiting_hold->id ) >+ ->status_is(403)->json_is( { error => 'Cancellation forbidden' } ); >+ >+ $cancellation_requestable = 1; >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/public/patrons/" . $patron->id . '/holds/' . $waiting_hold->id ) >+ ->status_is(202); >+ >+ my $cancellation_requests = $waiting_hold->cancellation_requests; >+ is( $cancellation_requests->count, 1, 'Cancellation request recorded' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 33573
:
152107
|
152108
|
152112
|
152113
|
152114
|
152115
| 152904 |
152905