Bugzilla – Attachment 90771 Details for
Bug 23154
Add pagination to /api/v1/checkouts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23154: Add pagination to /api/v1/checkouts
Bug-23154-Add-pagination-to-apiv1checkouts.patch (text/plain), 3.71 KB, created by
Julian Maurice
on 2019-06-19 09:17:29 UTC
(
hide
)
Description:
Bug 23154: Add pagination to /api/v1/checkouts
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2019-06-19 09:17:29 UTC
Size:
3.71 KB
patch
obsolete
>From 3a4416038872016896e211d784e3315bf6d5afe8 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 19 Jun 2019 11:10:14 +0200 >Subject: [PATCH] Bug 23154: Add pagination to /api/v1/checkouts > >Allow to use _page and _per_page query parameters for >/api/v1/checkouts >Also fix a timezone problem in t/db_dependent/api/v1/checkouts.t > >Test plan: >1. With your favorite REST tester tool, or directly in the browser, > fetch http://koha/api/v1/checkouts and check that you have results >2. Fetch /api/v1/checkouts?_per_page=1&page=1 and check that only the > first result is returned. Check that response contains headers > X-Total-Count and Link >3. Fetch /api/v1/checkouts?_per_page=1&page=2 and check that only the > second result is returned. Check that response contains headers > X-Total-Count and Link >4. prove t/db_dependent/api/v1/checkouts.t >--- > api/v1/swagger/paths/checkouts.json | 4 ++++ > t/db_dependent/api/v1/checkouts.t | 29 +++++++++++++++++++++++++++-- > 2 files changed, 31 insertions(+), 2 deletions(-) > >diff --git a/api/v1/swagger/paths/checkouts.json b/api/v1/swagger/paths/checkouts.json >index 6293401b8b..3cb15c49a1 100644 >--- a/api/v1/swagger/paths/checkouts.json >+++ b/api/v1/swagger/paths/checkouts.json >@@ -6,6 +6,10 @@ > "tags": ["patrons", "checkouts"], > "parameters": [{ > "$ref": "../parameters.json#/patron_id_qp" >+ }, { >+ "$ref": "../parameters.json#/page" >+ }, { >+ "$ref": "../parameters.json#/per_page" > }], > "produces": [ > "application/json" >diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t >index 170bf2b8ae..c4da7461c3 100644 >--- a/t/db_dependent/api/v1/checkouts.t >+++ b/t/db_dependent/api/v1/checkouts.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 53; >+use Test::More tests => 73; > use Test::MockModule; > use Test::Mojo; > use t::lib::Mocks; >@@ -110,6 +110,28 @@ $t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id") > ->json_is('/1/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) ) > ->json_hasnt('/2'); > >+$t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id&_per_page=1&_page=1") >+ ->status_is(200) >+ ->header_is('X-Total-Count', '2') >+ ->header_like('Link', qr|rel="next"|) >+ ->header_like('Link', qr|rel="first"|) >+ ->header_like('Link', qr|rel="last"|) >+ ->json_is('/0/patron_id' => $patron_id) >+ ->json_is('/0/item_id' => $item1->itemnumber) >+ ->json_is('/0/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due1 }) ) >+ ->json_hasnt('/1'); >+ >+$t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id&_per_page=1&_page=2") >+ ->status_is(200) >+ ->header_is('X-Total-Count', '2') >+ ->header_like('Link', qr|rel="prev"|) >+ ->header_like('Link', qr|rel="first"|) >+ ->header_like('Link', qr|rel="last"|) >+ ->json_is('/0/patron_id' => $patron_id) >+ ->json_is('/0/item_id' => $item2->itemnumber) >+ ->json_is('/0/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) ) >+ ->json_hasnt('/1'); >+ > $t->get_ok( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id) > ->status_is(200) > ->json_is('/patron_id' => $patron_id) >@@ -132,7 +154,10 @@ $dbh->do(q{ > VALUES (?, ?, ?, ?, ?) > }, {}, '*', '*', '*', 7, 1); > >-my $expected_datedue = DateTime->now->add(days => 14)->set(hour => 23, minute => 59, second => 0); >+my $expected_datedue = DateTime->now >+ ->set_time_zone('local') >+ ->add(days => 14) >+ ->set(hour => 23, minute => 59, second => 0); > $t->post_ok ( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id . "/renewal" ) > ->status_is(201) > ->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $expected_datedue }) ) >-- >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 23154
:
90771
|
90787
|
90910