Bugzilla – Attachment 174686 Details for
Bug 36454
Provide indication if a patron is expired or restricted on patron search autocomplete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36454: Fix and add API tests
Bug-36454-Fix-and-add-API-tests.patch (text/plain), 4.63 KB, created by
Jonathan Druart
on 2024-11-18 13:17:17 UTC
(
hide
)
Description:
Bug 36454: Fix and add API tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-11-18 13:17:17 UTC
Size:
4.63 KB
patch
obsolete
>From 0cd6102125a11d6ef5a2eb636cf0ec7d02a75e13 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 18 Nov 2024 13:57:13 +0100 >Subject: [PATCH] Bug 36454: Fix and add API tests > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/api/v1/patrons.t | 43 ++++++++++++++++++++++++--------- > 1 file changed, 31 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 22e0487ce0d..b3116116709 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -81,7 +81,7 @@ subtest 'list() tests' => sub { > > subtest 'librarian access tests' => sub { > >- plan tests => 21; >+ plan tests => 15; > > $schema->storage->txn_begin; > >@@ -137,19 +137,33 @@ subtest 'list() tests' => sub { > ->status_is(200) > ->json_is('/0/address2' => $librarian->address2); > >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >- AddDebarment( { borrowernumber => $patron->borrowernumber } ); >+ subtest 'restricted & expired' => sub { > >- $t->get_ok("//$userid:$password@/api/v1/patrons?restricted=" . Mojo::JSON->true . "&cardnumber=" . $patron->cardnumber ) >- ->status_is(200) >- ->json_has('/0/restricted') >- ->json_is( '/0/restricted' => Mojo::JSON->true ) >- ->json_hasnt('/1'); >+ plan tests => 13; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ AddDebarment( { borrowernumber => $patron->borrowernumber } ); > >- $t->get_ok( "//$userid:$password@/api/v1/patrons?" >- . 'q={"extended_attributes.type":"CODE"}' => >- { 'x-koha-embed' => 'extended_attributes' } ) >- ->status_is( 200, "Works, doesn't explode" ); >+ $t->get_ok("//$userid:$password@/api/v1/patrons?restricted=" . Mojo::JSON->true . "&cardnumber=" . $patron->cardnumber ) >+ ->status_is(200) >+ ->json_has('/0/restricted') >+ ->json_is( '/0/restricted' => Mojo::JSON->true ) >+ ->json_has('/0/expired') >+ ->json_is( '/0/expired' => Mojo::JSON->false ) >+ ->json_hasnt('/1'); >+ >+ $patron->dateexpiry(dt_from_string->subtract(days => 2))->store; >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber) >+ ->status_is(200) >+ ->json_has('/expired') >+ ->json_is( '/expired' => Mojo::JSON->true ); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/patrons?" >+ . 'q={"extended_attributes.type":"CODE"}' => >+ { 'x-koha-embed' => 'extended_attributes' } ) >+ ->status_is( 200, "Works, doesn't explode" ); >+ }; > > subtest 'searching date and date-time fields' => sub { > >@@ -443,6 +457,7 @@ subtest 'add() tests' => sub { > # delete RO attributes > delete $newpatron->{patron_id}; > delete $newpatron->{restricted}; >+ delete $newpatron->{expired}; > delete $newpatron->{anonymized}; > > # Create a library just to make sure its ID doesn't exist on the DB >@@ -488,6 +503,7 @@ subtest 'add() tests' => sub { > # delete RO attributes > delete $newpatron->{patron_id}; > delete $newpatron->{restricted}; >+ delete $newpatron->{expired}; > delete $newpatron->{anonymized}; > $patron_to_delete->delete; > >@@ -739,6 +755,7 @@ subtest 'update() tests' => sub { > # delete RO attributes > delete $newpatron->{patron_id}; > delete $newpatron->{restricted}; >+ delete $newpatron->{expired}; > delete $newpatron->{anonymized}; > > $t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron) >@@ -814,6 +831,7 @@ subtest 'update() tests' => sub { > # Put back the RO attributes > $newpatron->{patron_id} = $unauthorized_patron->to_api({ user => $authorized_patron })->{patron_id}; > $newpatron->{restricted} = $unauthorized_patron->to_api({ user => $authorized_patron })->{restricted}; >+ $newpatron->{expired} = $unauthorized_patron->to_api({ user => $authorized_patron })->{expired}; > $newpatron->{anonymized} = $unauthorized_patron->to_api({ user => $authorized_patron })->{anonymized}; > > my $got = $result->tx->res->json; >@@ -845,6 +863,7 @@ subtest 'update() tests' => sub { > # delete RO attributes > delete $newpatron->{patron_id}; > delete $newpatron->{restricted}; >+ delete $newpatron->{expired}; > delete $newpatron->{anonymized}; > > # attempt to update >-- >2.34.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 36454
:
171516
|
171630
|
171631
|
171632
|
171633
|
171839
|
171840
|
174671
|
174682
|
174684
|
174685
| 174686 |
174687