Bug 34024: Unit tests

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 3870b5a068)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Tomas Cohen Arazi 2023-07-31 14:00:36 -03:00 committed by Fridolin Somers
parent 6b2b54151f
commit 918c6ddb05
2 changed files with 30 additions and 5 deletions

View File

@ -694,13 +694,19 @@
schema:
$ref: "../swagger.yaml#/definitions/error"
"409":
description: Unable to perform action on hold
description: |
Unable to perform action on hold. Possible `error_code` attribute values:
* `hold_waiting`
* `hold_in_transit`
* `hold_in_processing`
schema:
$ref: "../swagger.yaml#/definitions/error"
"500":
description: Internal error
schema:
$ref: "../swagger.yaml#/definitions/error"
description: |
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
"503":
description: Under maintenance
schema:

View File

@ -1270,7 +1270,7 @@ subtest 'add() tests' => sub {
subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub {
plan tests => 28;
plan tests => 37;
$schema->storage->txn_begin;
@ -1403,6 +1403,25 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub {
is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'invalid pickup library not used, even if x-koha-override is passed' );
my $waiting_hold = $builder->build_object( { class => 'Koha::Holds', value => { found => 'W' } } );
my $in_processing_hold = $builder->build_object( { class => 'Koha::Holds', value => { found => 'P' } } );
my $in_transit_hold = $builder->build_object( { class => 'Koha::Holds', value => { found => 'T' } } );
$t->put_ok( "//$userid:$password@/api/v1/holds/"
. $waiting_hold->id
. "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } )->status_is(409)
->json_is( { error => q{Cannot change pickup location}, error_code => 'hold_waiting' } );
$t->put_ok( "//$userid:$password@/api/v1/holds/"
. $in_processing_hold->id
. "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } )->status_is(409)
->json_is( { error => q{Cannot change pickup location}, error_code => 'hold_in_processing' } );
$t->put_ok( "//$userid:$password@/api/v1/holds/"
. $in_transit_hold->id
. "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } )->status_is(409)
->json_is( { error => q{Cannot change pickup location}, error_code => 'hold_in_transit' } );
$schema->storage->txn_rollback;
};