Bug 25662: (follow-up) Add tests for the wrong patron_id added behaviour
This patch adds trivial tests for the new error (400) raised when the passed patron_id doesn't exist. To test: 1. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => SUCCESS: Tests pass! 2. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
69bdc94cd4
commit
deee485a24
|
|
@ -199,7 +199,7 @@ subtest "Test endpoints without permission" => sub {
|
|||
|
||||
subtest "Test endpoints with permission" => sub {
|
||||
|
||||
plan tests => 59;
|
||||
plan tests => 62;
|
||||
|
||||
$t->get_ok( "//$userid_1:$password@/api/v1/holds" )
|
||||
->status_is(200)
|
||||
|
|
@ -286,6 +286,20 @@ subtest "Test endpoints with permission" => sub {
|
|||
$t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data )
|
||||
->status_is(403)
|
||||
->json_like('/error', qr/itemAlreadyOnHold/);
|
||||
|
||||
my $to_delete_patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $deleted_patron_id = $to_delete_patron->borrowernumber;
|
||||
$to_delete_patron->delete;
|
||||
|
||||
my $tmp_patron_id = $post_data->{patron_id};
|
||||
$post_data->{patron_id} = $deleted_patron_id;
|
||||
$t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data )
|
||||
->status_is(400)
|
||||
->json_is( { error => 'patron_id not found' } );
|
||||
|
||||
# Restore the original patron_id as it is expected by the next subtest
|
||||
# FIXME: this tests need to be rewritten from scratch
|
||||
$post_data->{patron_id} = $tmp_patron_id;
|
||||
};
|
||||
|
||||
subtest 'Reserves with itemtype' => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue