Bugzilla – Attachment 117136 Details for
Bug 27366
Add GET /patrons/:patron_id/holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27366: Unit tests
Bug-27366-Unit-tests.patch (text/plain), 3.17 KB, created by
Martin Renvoize (ashimema)
on 2021-02-22 10:42:21 UTC
(
hide
)
Description:
Bug 27366: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-02-22 10:42:21 UTC
Size:
3.17 KB
patch
obsolete
>From 5dfa9ce65cc50871d0929c6d7b952c537cfdda2e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 8 Jan 2021 13:16:19 -0300 >Subject: [PATCH] Bug 27366: Unit tests > >Addd unit tests for the new patrons/{patron_id}/holds api route. > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/patrons_holds.t | 70 +++++++++++++++++++++++++++ > 1 file changed, 70 insertions(+) > create mode 100755 t/db_dependent/api/v1/patrons_holds.t > >diff --git a/t/db_dependent/api/v1/patrons_holds.t b/t/db_dependent/api/v1/patrons_holds.t >new file mode 100755 >index 0000000000..e18de8cae5 >--- /dev/null >+++ b/t/db_dependent/api/v1/patrons_holds.t >@@ -0,0 +1,70 @@ >+#!/usr/bin/env perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::Mojo; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new(); >+ >+my $t = Test::Mojo->new('Koha::REST::V1'); >+ >+t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+subtest 'list() tests' => sub { >+ >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { flags => 2 ** 4 } # 'borrowers' flag == 4 >+ }); >+ my $password = 'thePassword123'; >+ $patron->set_password({ password => $password, skip_validation => 1 }); >+ my $userid = $patron->userid; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds') >+ ->status_is( 200, 'SWAGGER3.2.2' ) >+ ->json_is( [] ); >+ >+ my $hold_1 = $builder->build_object({ class => 'Koha::Holds', value => { borrowernumber => $patron->id } }); >+ my $hold_2 = $builder->build_object({ class => 'Koha::Holds', value => { borrowernumber => $patron->id } }); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds') >+ ->status_is( 200, 'SWAGGER3.2.2' ) >+ ->json_is( '' => [ $hold_1->to_api, $hold_2->to_api ], 'Holds retrieved' ); >+ >+ my $non_existent_patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $non_existent_patron_id = $non_existent_patron->id; >+ # get rid of the patron >+ $non_existent_patron->delete; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $non_existent_patron_id . '/holds') >+ ->status_is( 404 ) >+ ->json_is( '/error' => 'Patron not found' ); >+ >+ $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 27366
:
114971
|
114972
|
114973
|
114980
|
114981
|
114982
|
116015
|
116016
|
116017
|
117135
| 117136 |
117137