Bugzilla – Attachment 125171 Details for
Bug 27947
Add default cancellation reasons to article requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27947: Add regression tests for routes
Bug-27947-Add-regression-tests-for-routes.patch (text/plain), 5.22 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-09-22 19:36:35 UTC
(
hide
)
Description:
Bug 27947: Add regression tests for routes
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-09-22 19:36:35 UTC
Size:
5.22 KB
patch
obsolete
>From fdda5bdaf106e36cadc97bcb057e87c921a4a8eb Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 17 Sep 2021 12:13:09 -0300 >Subject: [PATCH] Bug 27947: Add regression tests for routes > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/article_requests.t | 139 +++++++++++++++++++++++ > 1 file changed, 139 insertions(+) > create mode 100755 t/db_dependent/api/v1/article_requests.t > >diff --git a/t/db_dependent/api/v1/article_requests.t b/t/db_dependent/api/v1/article_requests.t >new file mode 100755 >index 0000000000..5f9ae1cd4e >--- /dev/null >+++ b/t/db_dependent/api/v1/article_requests.t >@@ -0,0 +1,139 @@ >+#!/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 => 2; >+use Test::Mojo; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+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 'cancel() tests' => sub { >+ >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ my $authorized_patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ } >+ ); >+ my $password = 'thePassword123'; >+ $authorized_patron->set_password( >+ { password => $password, skip_validation => 1 } ); >+ my $userid = $authorized_patron->userid; >+ >+ my $deleted_article_requet = >+ $builder->build_object( { class => 'Koha::ArticleRequests' } ); >+ my $deleted_article_requet_id = $deleted_article_requet->id; >+ $deleted_article_requet->delete; >+ >+ $t->delete_ok( >+"//$userid:$password@/api/v1/article_requests/$deleted_article_requet_id" >+ )->status_is(404)->json_is( { error => "Article request not found" } ); >+ >+ my $article_request = >+ $builder->build_object( { class => 'Koha::ArticleRequests' } ); >+ >+ my $reason = 'A reason'; >+ my $notes = 'Some notes'; >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/article_requests/" >+ . $article_request->id >+ . "?cancellation_reason=$reason¬es=$notes" ) >+ ->status_is( 204, 'SWAGGER3.2.4' )->content_is( q{}, 'SWAGGER3.2.4' ); >+ >+ # refresh object >+ $article_request->discard_changes; >+ >+ is( $article_request->cancellation_reason, >+ $reason, 'Reason stored correctly' ); >+ is( $article_request->notes, $notes, 'Notes stored correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'patron_cancel() tests' => sub { >+ >+ plan tests => 10; >+ >+ t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); >+ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { privacy_guarantor_checkouts => 0 } >+ } >+ ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ my $patron_id = $patron->borrowernumber; >+ >+ my $deleted_article_requet = $builder->build_object( { class => 'Koha::ArticleRequests' } ); >+ my $deleted_article_requet_id = $deleted_article_requet->id; >+ $deleted_article_requet->delete; >+ >+ my $another_patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $another_patron_id = $another_patron->id; >+ >+ $t->delete_ok("//$userid:$password@/api/v1/public/patrons/$another_patron_id/article_requests/$deleted_article_requet_id") >+ ->status_is(403); >+ >+ $t->delete_ok("//$userid:$password@/api/v1/public/patrons/$patron_id/article_requests/$deleted_article_requet_id") >+ ->status_is(404) >+ ->json_is( { error => "Article request not found" } ); >+ >+ my $article_request = $builder->build_object( >+ { >+ class => 'Koha::ArticleRequests', >+ value => { borrowernumber => $patron->id } >+ } >+ ); >+ >+ my $reason = 'A reason'; >+ my $notes = 'Some notes'; >+ >+ $t->delete_ok( >+ "//$userid:$password@/api/v1/public/patrons/$patron_id/article_requests/" >+ . $article_request->id >+ . "?cancellation_reason=$reason¬es=$notes" ) >+ ->status_is( 204, 'SWAGGER3.2.4' ) >+ ->content_is( q{}, 'SWAGGER3.2.4' ); >+ >+ # refresh object >+ $article_request->discard_changes; >+ >+ is( $article_request->cancellation_reason, $reason, 'Reason stored correctly' ); >+ is( $article_request->notes, $notes, 'Notes stored correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 27947
:
124063
|
124064
|
124065
|
124849
|
124850
|
124851
|
124952
|
124953
|
124954
|
124955
|
124956
|
124993
|
124994
|
124995
|
124996
|
124997
|
124998
|
124999
|
125002
|
125003
|
125004
|
125005
|
125006
|
125007
|
125008
|
125009
|
125010
|
125016
|
125038
|
125039
|
125040
|
125041
|
125042
|
125043
|
125044
|
125045
|
125046
|
125047
|
125165
|
125166
|
125167
|
125168
|
125169
|
125170
| 125171 |
125172
|
125173
|
125174
|
125739
|
125740