From d81c955e48c2843a3558bb81c6105467dc776707 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Wed, 12 Oct 2022 13:29:48 -0400 Subject: [PATCH] Bug 24860: (QA follow-up) Add unit tests to cover Koha::REST::V1::Holds::add --- t/db_dependent/api/v1/holds.t | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index d85f88bab9..adc5429660 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -1097,7 +1097,7 @@ subtest 'edit() tests' => sub { subtest 'add() tests' => sub { - plan tests => 16; + plan tests => 21; $schema->storage->txn_begin; @@ -1178,6 +1178,37 @@ subtest 'add() tests' => sub { pickup_library_id => $library_1->branchcode, }; + $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $biblio_hold_data ) + ->status_is(400) + ->json_is({ error => 'The supplied pickup location is not valid' }); + + $biblio_hold_data->{pickup_library_id} = $library_2->branchcode; + $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $biblio_hold_data ) + ->status_is(201); + + # Test biblio-level holds + my $item_group = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store(); + $biblio_hold = $builder->build_object( + { + class => "Koha::Holds", + value => { + biblionumber => $biblio->biblionumber, + branchcode => $library_3->branchcode, + itemnumber => undef, + priority => 1, + item_group_id => $item_group->id, + } + } + ); + + $biblio_hold_api_data = $biblio_hold->to_api; + $biblio_hold->delete; + $biblio_hold_data = { + biblio_id => $biblio_hold_api_data->{biblio_id}, + patron_id => $biblio_hold_api_data->{patron_id}, + pickup_library_id => $library_1->branchcode, + }; + $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $biblio_hold_data ) ->status_is(400) ->json_is({ error => 'The supplied pickup location is not valid' }); -- 2.30.2