Bugzilla – Attachment 121236 Details for
Bug 28369
additionalProperties missing in holds routes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28369: Regression tests
Bug-28369-Regression-tests.patch (text/plain), 8.88 KB, created by
Joonas Kylmälä
on 2021-05-20 12:21:02 UTC
(
hide
)
Description:
Bug 28369: Regression tests
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2021-05-20 12:21:02 UTC
Size:
8.88 KB
patch
obsolete
>From ab03786c61ba857bb66057d59aabeebc3c0bbf4d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 18 May 2021 09:06:34 -0300 >Subject: [PATCH] Bug 28369: Regression tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > t/db_dependent/api/v1/holds.t | 83 ++++++++++++++++++++++++------------------- > 1 file changed, 47 insertions(+), 36 deletions(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 674172e605..7d9cf295e4 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -155,16 +155,15 @@ my $suspended_until = DateTime->now->add(days => 10)->truncate( to => 'day' ); > my $expiration_date = DateTime->now->add(days => 10)->truncate( to => 'day' ); > > my $post_data = { >- patron_id => int($patron_1->borrowernumber), >- biblio_id => int($biblio_1->biblionumber), >- item_id => int($item_1->itemnumber), >+ patron_id => $patron_1->borrowernumber, >+ biblio_id => $biblio_1->biblionumber, >+ item_id => $item_1->itemnumber, > pickup_library_id => $branchcode, >- expiration_date => output_pref({ dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 }), >- priority => 2, >+ expiration_date => output_pref( { dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 } ), > }; >-my $put_data = { >- priority => 2, >- suspended_until => output_pref({ dt => $suspended_until, dateformat => 'rfc3339' }), >+my $patch_data = { >+ priority => 2, >+ suspended_until => output_pref( { dt => $suspended_until, dateformat => 'rfc3339' } ), > }; > > subtest "Test endpoints without authentication" => sub { >@@ -173,7 +172,7 @@ subtest "Test endpoints without authentication" => sub { > ->status_is(401); > $t->post_ok('/api/v1/holds') > ->status_is(401); >- $t->put_ok('/api/v1/holds/0') >+ $t->patch_ok('/api/v1/holds/0') > ->status_is(401); > $t->delete_ok('/api/v1/holds/0') > ->status_is(401); >@@ -192,7 +191,7 @@ subtest "Test endpoints without permission" => sub { > $t->post_ok( "//$nopermission_userid:$password@/api/v1/holds" => json => $post_data ) > ->status_is(403); > >- $t->put_ok( "//$nopermission_userid:$password@/api/v1/holds/0" => json => $put_data ) >+ $t->patch_ok( "//$nopermission_userid:$password@/api/v1/holds/0" => json => $patch_data ) > ->status_is(403); > > $t->delete_ok( "//$nopermission_userid:$password@/api/v1/holds/0" ) >@@ -218,7 +217,7 @@ subtest "Test endpoints with permission" => sub { > ->status_is(204, 'SWAGGER3.2.4') > ->content_is('', 'SWAGGER3.3.4'); > >- $t->put_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id" => json => $put_data ) >+ $t->patch_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id" => json => $patch_data ) > ->status_is(404) > ->json_has('/error'); > >@@ -262,12 +261,12 @@ subtest "Test endpoints with permission" => sub { > ->status_is(403) > ->json_like('/error', qr/itemAlreadyOnHold/); > >- $post_data->{biblionumber} = int($biblio_2->biblionumber); >- $post_data->{itemnumber} = int($item_2->itemnumber); >+ $post_data->{biblio_id} = $biblio_2->biblionumber; >+ $post_data->{item_id} = $item_2->itemnumber; > > $t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) > ->status_is(403) >- ->json_like('/error', qr/itemAlreadyOnHold/); >+ ->json_like('/error', qr/Hold cannot be placed. Reason: tooManyReserves/); > > my $to_delete_patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $deleted_patron_id = $to_delete_patron->borrowernumber; >@@ -326,13 +325,12 @@ subtest 'test AllowHoldDateInFuture' => sub { > my $future_hold_date = DateTime->now->add(days => 10)->truncate( to => 'day' ); > > my $post_data = { >- patron_id => int($patron_1->borrowernumber), >- biblio_id => int($biblio_1->biblionumber), >- item_id => int($item_1->itemnumber), >+ patron_id => $patron_1->borrowernumber, >+ biblio_id => $biblio_1->biblionumber, >+ item_id => $item_1->itemnumber, > pickup_library_id => $branchcode, >- expiration_date => output_pref({ dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 }), >- hold_date => output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 }), >- priority => 2, >+ expiration_date => output_pref( { dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 } ), >+ hold_date => output_pref( { dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 } ), > }; > > t::lib::Mocks::mock_preference( 'AllowHoldDateInFuture', 0 ); >@@ -953,10 +951,13 @@ subtest 'edit() tests' => sub { > } > ); > >- my $biblio_hold_data = $biblio_hold->to_api; >- $biblio_hold_data->{pickup_library_id} = $library_1->branchcode; >+ my $biblio_hold_api_data = $biblio_hold->to_api; >+ my $biblio_hold_data = { >+ pickup_library_id => $library_1->branchcode, >+ priority => $biblio_hold_api_data->{priority} >+ }; > >- $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" > . $biblio_hold->id > => json => $biblio_hold_data ) > ->status_is(400) >@@ -965,14 +966,14 @@ subtest 'edit() tests' => sub { > $biblio_hold->discard_changes; > is( $biblio_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); > >- $t->put_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id > => { 'x-koha-override' => 'any' } > => json => $biblio_hold_data ) > ->status_is(200) > ->json_has( '/pickup_library_id' => $library_1->id ); > > $biblio_hold_data->{pickup_library_id} = $library_2->branchcode; >- $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" > . $biblio_hold->id > => json => $biblio_hold_data ) > ->status_is(200); >@@ -993,10 +994,13 @@ subtest 'edit() tests' => sub { > } > ); > >- my $item_hold_data = $item_hold->to_api; >- $item_hold_data->{pickup_library_id} = $library_1->branchcode; >+ my $item_hold_api_data = $item_hold->to_api; >+ my $item_hold_data = { >+ pickup_library_id => $library_1->branchcode, >+ priority => $item_hold_api_data->{priority} >+ }; > >- $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" > . $item_hold->id > => json => $item_hold_data ) > ->status_is(400) >@@ -1005,14 +1009,14 @@ subtest 'edit() tests' => sub { > $item_hold->discard_changes; > is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); > >- $t->put_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id > => { 'x-koha-override' => 'any' } > => json => $item_hold_data ) > ->status_is(200) > ->json_has( '/pickup_library_id' => $library_1->id ); > > $item_hold_data->{pickup_library_id} = $library_2->branchcode; >- $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" > . $item_hold->id > => json => $item_hold_data ) > ->status_is(200); >@@ -1098,10 +1102,13 @@ subtest 'add() tests' => sub { > } > ); > >- my $biblio_hold_data = $biblio_hold->to_api; >+ my $biblio_hold_api_data = $biblio_hold->to_api; > $biblio_hold->delete; >- $biblio_hold_data->{pickup_library_id} = $library_1->branchcode; >- delete $biblio_hold_data->{hold_id}; >+ my $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) >@@ -1124,10 +1131,14 @@ subtest 'add() tests' => sub { > } > ); > >- my $item_hold_data = $item_hold->to_api; >+ my $item_hold_api_data = $item_hold->to_api; > $item_hold->delete; >- $item_hold_data->{pickup_library_id} = $library_1->branchcode; >- delete $item_hold->{hold_id}; >+ my $item_hold_data = { >+ biblio_id => $item_hold_api_data->{biblio_id}, >+ item_id => $item_hold_api_data->{item_id}, >+ patron_id => $item_hold_api_data->{patron_id}, >+ pickup_library_id => $library_1->branchcode, >+ }; > > $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $item_hold_data ) > ->status_is(400) >-- >2.11.0
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 28369
:
121105
|
121106
|
121119
|
121131
|
121132
|
121133
|
121233
|
121234
|
121235
| 121236 |
121237
|
121238