Bugzilla – Attachment 119167 Details for
Bug 27894
Add visual feedback on overridden pickup locations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27894: Unit tests
Bug-27894-Unit-tests.patch (text/plain), 3.73 KB, created by
Katrin Fischer
on 2021-04-03 23:23:40 UTC
(
hide
)
Description:
Bug 27894: Unit tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2021-04-03 23:23:40 UTC
Size:
3.73 KB
patch
obsolete
>From e90b6f0ca33f8cebd1eb01a1eecbf32ac7011f89 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 11 Mar 2021 09:26:32 -0300 >Subject: [PATCH] Bug 27894: Unit tests > >This patch adds tests for the changed behavior. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/api/v1/holds.t | 42 +++++++++++++++++++++++++++++++++++------- > 1 file changed, 35 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 41cf559ca9..ab0f68d9d0 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -687,13 +687,26 @@ subtest 'add() tests (maxreserves behaviour)' => sub { > > subtest 'pickup_locations() tests' => sub { > >- plan tests => 9; >+ plan tests => 12; > > $schema->storage->txn_begin; > >- my $library_1 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'A' } }); >- my $library_2 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'B' } }); >- my $library_3 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'C' } }); >+ t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); >+ >+ # Small trick to ease testing >+ Koha::Libraries->search->update({ pickup_location => 0 }); >+ >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'A', pickup_location => 1 } }); >+ my $library_2 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'B', pickup_location => 1 } }); >+ my $library_3 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'C', pickup_location => 1 } }); >+ >+ my $library_1_api = $library_1->to_api(); >+ my $library_2_api = $library_2->to_api(); >+ my $library_3_api = $library_3->to_api(); >+ >+ $library_1_api->{needs_override} = Mojo::JSON->false; >+ $library_2_api->{needs_override} = Mojo::JSON->false; >+ $library_3_api->{needs_override} = Mojo::JSON->false; > > my $patron = $builder->build_object( > { >@@ -790,19 +803,34 @@ subtest 'pickup_locations() tests' => sub { > $t->get_ok( "//$userid:$password@/api/v1/holds/" > . $hold_1->id > . "/pickup_locations" ) >- ->json_is( [ $library_2->to_api, $library_3->to_api ] ); >+ ->json_is( [ $library_2_api, $library_3_api ] ); > > $t->get_ok( "//$userid:$password@/api/v1/holds/" > . $hold_2->id > . "/pickup_locations" ) >- ->json_is( [ $library_1->to_api, $library_2->to_api ] ); >+ ->json_is( [ $library_1_api, $library_2_api ] ); > > # filtering works! > $t->get_ok( "//$userid:$password@/api/v1/holds/" > . $hold_2->id > . '/pickup_locations?q={"marc_org_code": { "-like": "A%" }}' ) >- ->json_is( [ $library_1->to_api ] ); >+ ->json_is( [ $library_1_api ] ); >+ >+ t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); >+ >+ my $library_4 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 0, marcorgcode => 'X' } }); >+ my $library_5 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1, marcorgcode => 'Y' } }); >+ >+ my $library_5_api = $library_5->to_api(); >+ $library_5_api->{needs_override} = Mojo::JSON->true; > >+ # bibli-level mock doesn't include library_1 as valid pickup location >+ $library_1_api->{needs_override} = Mojo::JSON->true; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold_1->id >+ . "/pickup_locations?_order_by=marc_org_code" ) >+ ->json_is( [ $library_1_api, $library_2_api, $library_3_api, $library_5_api ] ); > > $schema->storage->txn_rollback; > }; >-- >2.11.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 27894
:
118121
|
118122
|
118123
|
118583
|
118584
|
118585
| 119167 |
119168
|
119169