Bugzilla – Attachment 151043 Details for
Bug 24400
REST API: Checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24400: Unit tests for all responses of checkout API
Bug-24400-Unit-tests-for-all-responses-of-checkout.patch (text/plain), 3.33 KB, created by
Alex Buckley
on 2023-05-11 04:30:44 UTC
(
hide
)
Description:
Bug 24400: Unit tests for all responses of checkout API
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2023-05-11 04:30:44 UTC
Size:
3.33 KB
patch
obsolete
>From d664ccadfeb7d61a7496ce60c43e51c99c946008 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Thu, 11 May 2023 04:29:18 +0000 >Subject: [PATCH] Bug 24400: Unit tests for all responses of checkout API > >--- > t/db_dependent/api/v1/items.t | 39 +++++++++++++++++++++++++++++------ > 1 file changed, 33 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/api/v1/items.t b/t/db_dependent/api/v1/items.t >index b753518aa35..58323d926f8 100755 >--- a/t/db_dependent/api/v1/items.t >+++ b/t/db_dependent/api/v1/items.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockModule; > use Test::Mojo; > use Test::Warn; >@@ -30,6 +30,7 @@ use t::lib::Mocks; > use Mojo::JSON qw(encode_json); > > use C4::Auth; >+use C4::Circulation; > use Koha::Items; > use Koha::Database; > >@@ -575,11 +576,12 @@ subtest 'pickup_locations() tests' => sub { > > subtest 'checkout() tests' => sub { > >- plan tests => 12; >+ plan tests => 27; > > $schema->storage->txn_begin; > > my $item = $builder->build_sample_item; >+ my $item2 = $builder->build_sample_item; > my $patron = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -606,19 +608,21 @@ subtest 'checkout() tests' => sub { > > my $userid = $nonprivilegedpatron->userid; > my $itemid = $item->id; >- my $patronid = $patron->id; >+ my $itemid2 = $item2->id; >+ my $patronid = $patron->borrowernumber; > my $non_existent_code = $item->itemnumber; > >- $t->get_ok( "//$userid:$password@/api/v1/items/$itemid/checkout/$patronid" ) >+ $t->post_ok( "//$userid:$password@/api/v1/items/$itemid/checkout/$patronid" ) > ->status_is(403) > ->json_is( > '/error' => 'Authorization failure. Missing required permission(s).' ); > > $t->get_ok( "//$userid:$password@/api/v1/items/" . $non_existent_code ) >- ->status_is(404) >+ ->status_is(403) > ->json_is( >- '/error' => 'Item not found' ); >+ '/error' => 'Authorization failure. Missing required permission(s).' ); > >+ $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > > $t->get_ok( "//$userid:$password@/api/v1/items?_per_page=10" ) >@@ -632,12 +636,35 @@ subtest 'checkout() tests' => sub { > ->status_is(200) > ->json_is( '' => [ $item->to_api ], 'SWAGGER3.3.2'); > >+ $patron->flags(1)->store; >+ my $deleted_patron_id = $nonprivilegedpatron->id; >+ $nonprivilegedpatron->delete; >+ $t->post_ok( "//$userid:$password@/api/v1/items/$itemid/checkout/$deleted_patron_id" ) >+ ->status_is(400) >+ ->json_is( '/error' => 'Patron not found' ); >+ > my $barcode = $item->barcode; > $item->delete; > >+ $t->post_ok("//$userid:$password@/api/v1/items/$itemid/checkout/$patronid") >+ ->status_is(404); >+ > $t->get_ok( "//$userid:$password@/api/v1/items?external_id=" . $item->barcode ) > ->status_is(200) > ->json_is( '' => [] ); > >+ $t->get_ok( "//$userid:$password@/api/v1/items/" . $non_existent_code ) >+ ->status_is(404) >+ ->json_is( >+ '/error' => 'Item not found' ); >+ >+ is( $patron->checkouts->count, 0); >+ >+ $t->post_ok( "//$userid:$password@/api/v1/items/$itemid2/checkout/$patronid") >+ ->status_is(201); >+ >+ is( $patron->checkouts->count, 1); >+ > $schema->storage->txn_rollback; > }; >+ >-- >2.20.1
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 24400
:
150449
|
150495
|
150920
|
150921
|
151043
|
151044