Bug 36100: Update unit tests for add

This patch updates the unit tests for booking add to confirm that
without readOnly we still return an error should a user attempt to
submit a booking with a booking_id that would clash.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit d810b3663b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2024-02-15 12:33:26 +00:00 committed by Fridolin Somers
parent b051e53bc9
commit 733546cf5f

View file

@ -224,7 +224,8 @@ subtest 'add() tests' => sub {
my $unauth_userid = $patron->userid;
my $biblio = $builder->build_sample_biblio;
my $item = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } );
my $item1 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } );
my $item2 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } );
my $booking = {
biblio_id => $biblio->id,
item_id => undef,
@ -261,14 +262,8 @@ subtest 'add() tests' => sub {
# Authorized attempt to create with existing id
$booking->{booking_id} = $booking_id;
$t->post_ok( "//$userid:$password@/api/v1/bookings" => json => $booking )->status_is(400)->json_is(
"/errors" => [
{
message => "Read-only.",
path => "/body/booking_id"
}
]
);
$t->post_ok( "//$userid:$password@/api/v1/bookings" => json => $booking )->status_is(400)
->json_is( "/error" => "Duplicate booking_id" );
# TODO: Test bookings clashes
# TODO: Test item auto-assignment