Bugzilla – Attachment 117540 Details for
Bug 27797
Make POST /holds use the stashed koha.overrides
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27797: Unit tests
Bug-27797-Unit-tests.patch (text/plain), 4.05 KB, created by
Martin Renvoize (ashimema)
on 2021-03-02 17:14:19 UTC
(
hide
)
Description:
Bug 27797: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-02 17:14:19 UTC
Size:
4.05 KB
patch
obsolete
>From 4267707e57f6e6bf8091f7b9c19e3a47d8f59f8e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 26 Feb 2021 10:50:46 -0300 >Subject: [PATCH] Bug 27797: Unit tests > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/holds.t | 76 ++++++++++++++++++++++++----------- > 1 file changed, 52 insertions(+), 24 deletions(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 41cf559ca9..57a318513d 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -354,48 +354,76 @@ subtest 'test AllowHoldDateInFuture' => sub { > ->json_is('/hold_date', output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 })); > }; > >-subtest 'test AllowHoldPolicyOverride' => sub { >+$schema->storage->txn_rollback; > >- plan tests => 7; >+subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub { > >- $dbh->do('DELETE FROM reserves'); >+ plan tests => 8; > >- Koha::CirculationRules->set_rules( >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( > { >- itemtype => undef, >- branchcode => undef, >- rules => { >- holdallowed => 1 >- } >+ class => 'Koha::Patrons', >+ value => { flags => 1 } > } > ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ $patron->discard_changes; >+ my $userid = $patron->userid; > > t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); > > # Make sure pickup location checks doesn't get in the middle > my $mock_biblio = Test::MockModule->new('Koha::Biblio'); >- $mock_biblio->mock( 'pickup_locations', sub { return Koha::Libraries->search; }); >- my $mock_item = Test::MockModule->new('Koha::Item'); >- $mock_item->mock( 'pickup_locations', sub { return Koha::Libraries->search }); >+ $mock_biblio->mock( 'pickup_locations', >+ sub { return Koha::Libraries->search; } ); >+ my $mock_item = Test::MockModule->new('Koha::Item'); >+ $mock_item->mock( 'pickup_locations', >+ sub { return Koha::Libraries->search } ); >+ >+ my $can_item_be_reserved_result; >+ my $mock_reserves = Test::MockModule->new('C4::Reserves'); >+ $mock_reserves->mock( >+ 'CanItemBeReserved', >+ sub { >+ return $can_item_be_reserved_result; >+ } >+ ); > >- $t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) >+ my $item = $builder->build_sample_item; >+ >+ my $post_data = { >+ item_id => $item->id, >+ biblio_id => $item->biblionumber, >+ patron_id => $patron->id, >+ pickup_library_id => $patron->branchcode, >+ }; >+ >+ $can_item_be_reserved_result = { status => 'ageRestricted' }; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $post_data ) > ->status_is(403) >- ->json_has('/error'); >+ ->json_is( '/error' => "Hold cannot be placed. Reason: ageRestricted" ); > > t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); > >- $t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) >- ->status_is(403); >+ $can_item_be_reserved_result = { status => 'pickupNotInHoldGroup' }; > >- $t->post_ok( >- "//$userid_3:$password@/api/v1/holds" => { >- 'x-koha-override' => >- encode_json( { AllowHoldPolicyOverride => Mojo::JSON->true } ) >- } => json => $post_data >- )->status_is(201); >-}; >+ $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $post_data ) >+ ->status_is(403) >+ ->json_is( >+ '/error' => "Hold cannot be placed. Reason: pickupNotInHoldGroup" ); > >-$schema->storage->txn_rollback; >+ $can_item_be_reserved_result = { status => 'OK' }; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/holds" => >+ { 'x-koha-override' => 'any' } => json => $post_data ) >+ ->status_is(201); >+ >+ $schema->storage->txn_rollback; >+}; > > subtest 'suspend and resume tests' => sub { > >-- >2.20.1
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 27797
:
117498
|
117499
|
117540
|
117541
|
117761
|
117762
|
117763
|
117920
|
117929
|
117930
|
120285
|
120286
|
120287
|
120288
|
120289
|
120290