Bugzilla – Attachment 114337 Details for
Bug 18729
Librarian unable to update hold pickup library from patron pages without "modify_holds_priority" permission
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18729: Add more tests
Bug-18729-Add-more-tests.patch (text/plain), 4.83 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-12-11 12:14:03 UTC
(
hide
)
Description:
Bug 18729: Add more tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-12-11 12:14:03 UTC
Size:
4.83 KB
patch
obsolete
>From 61395602878d9e087d88d196bae96a3caf64cb03 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 11 Dec 2020 09:11:15 -0300 >Subject: [PATCH] Bug 18729: Add more tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/holds.t | 85 +++++++++++++++++++++++++++++++++-- > 1 file changed, 82 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index cb683fd8192..b8a3318f75f 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -790,13 +790,13 @@ subtest 'pickup_locations() tests' => sub { > > subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > >- plan tests => 4; >+ plan tests => 16; > > $schema->storage->txn_begin; > > my $password = 'AbcdEFG123'; > >- my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); > my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); > > my $patron = $builder->build_object( >@@ -818,7 +818,33 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); > t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > >+ my $libraries_rs = Koha::Libraries->search( >+ { >+ branchcode => { >+ '-in' => [ $library_1->branchcode, $library_2->branchcode ] >+ } >+ } >+ ); >+ >+ my $mocked_biblio = Test::MockModule->new('Koha::Biblio'); >+ $mocked_biblio->mock( 'pickup_locations', sub { >+ return $libraries_rs; >+ }); >+ >+ my $mocked_item = Test::MockModule->new('Koha::Item'); >+ $mocked_item->mock( 'pickup_locations', sub { >+ return $libraries_rs; >+ }); >+ > my $biblio = $builder->build_sample_biblio; >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library_1->branchcode >+ } >+ ); >+ >+ # biblio-level hold > my $hold = Koha::Holds->find( > AddReserve( > { >@@ -826,13 +852,66 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > borrowernumber => $patron->borrowernumber, > biblionumber => $biblio->biblionumber, > priority => 1, >+ itemnumber => undef, > } > ) > ); > > $t->put_ok( "//$userid:$password@/api/v1/holds/" > . $hold->id >- . "/pickup_location" => json => $library_2->branchcode )->status_is(200)->json_is($library_2->branchcode); >+ . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } ) >+ ->status_is(200) >+ ->json_is({ pickup_library_id => $library_2->branchcode }); >+ >+ is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' ); >+ >+ $libraries_rs = Koha::Libraries->search({ branchcode => $library_1->branchcode }); >+ >+ $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold->id >+ . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } ) >+ ->status_is(400) >+ ->json_is({ error => 'Invalid pickup location passed' }); >+ >+ is( $hold->discard_changes->branchcode->branchcode, $library_1->branchcode, 'pickup library unchanged' ); >+ >+ # item-level hold >+ $hold = Koha::Holds->find( >+ AddReserve( >+ { >+ branchcode => $library_1->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ itemnumber => $item->itemnumber, >+ } >+ ) >+ ); >+ >+ $libraries_rs = Koha::Libraries->search({ branchcode => $library_1->branchcode }); >+ >+ # Attempt to use an invalid pickup locations ends in 400 >+ $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold->id >+ . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } ) >+ ->status_is(400) >+ ->json_is({ error => 'Invalid pickup location passed' }); >+ >+ is( $hold->discard_changes->branchcode->branchcode, $library_1->branchcode, 'pickup library unchanged' ); >+ >+ $libraries_rs = Koha::Libraries->search( >+ { >+ branchcode => { >+ '-in' => [ $library_1->branchcode, $library_2->branchcode ] >+ } >+ } >+ ); >+ >+ $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold->id >+ . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } ) >+ ->status_is(200) >+ ->json_is({ pickup_library_id => $library_2->branchcode }); > > is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' ); > >-- >2.29.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 18729
:
114067
|
114311
|
114337
|
114388
|
114389
|
114390
|
114391
|
114393
|
114394
|
114395
|
114396
|
117656
|
117657
|
117658
|
117659
|
119711
|
119712
|
119713
|
119714