Bugzilla – Attachment 118121 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.61 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-03-11 13:55:18 UTC
(
hide
)
Description:
Bug 27894: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-03-11 13:55:18 UTC
Size:
3.61 KB
patch
obsolete
>From 12474f328f2947ca36d11b16d3abcfad9e2ea1b2 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. >--- > 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 56ae481cb8d..1e3a198c120 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -738,13 +738,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( > { >@@ -841,19 +854,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.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 27894
:
118121
|
118122
|
118123
|
118583
|
118584
|
118585
|
119167
|
119168
|
119169