Bugzilla – Attachment 50144 Details for
Bug 16246
Return all reserves columns in ILS-DI GetRecords response
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16246: Add tests for ILS-DI GetRecords
Bug-16246-Add-tests-for-ILS-DI-GetRecords.patch (text/plain), 5.73 KB, created by
Julian Maurice
on 2016-04-12 12:25:23 UTC
(
hide
)
Description:
Bug 16246: Add tests for ILS-DI GetRecords
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2016-04-12 12:25:23 UTC
Size:
5.73 KB
patch
obsolete
>From 762ff8d31e2914d8dd941de26a2b32b055e3e48b Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 12 Apr 2016 13:54:13 +0200 >Subject: [PATCH] Bug 16246: Add tests for ILS-DI GetRecords > >+ remove some warnings in C4/ILSDI/Services.pm >--- > C4/ILSDI/Services.pm | 14 ++++++--- > t/db_dependent/ILSDI_Services.t | 70 +++++++++++++++++++++++++++++++++++++---- > 2 files changed, 73 insertions(+), 11 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 8a8166c..eaa9509 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -328,7 +328,7 @@ Parameters: > > sub AuthenticatePatron { > my ($cgi) = @_; >- my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $cgi->param('username'), $cgi->param('password') ); >+ my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, scalar $cgi->param('username'), scalar $cgi->param('password') ); > if ( $status ) { > # Get the borrower > my $borrower = GetMember( cardnumber => $cardnumber ); >@@ -377,7 +377,8 @@ sub GetPatronInfo { > delete $borrower->{'password'}; > > # Contact fields management >- if ( $cgi->param('show_contact') eq "0" ) { >+ my $show_contact = $cgi->param('show_contact') // '1'; >+ if ( $show_contact eq "0" ) { > > # Define contact fields > my @contactfields = ( >@@ -394,7 +395,8 @@ sub GetPatronInfo { > } > > # Fines management >- if ( $cgi->param('show_fines') eq "1" ) { >+ my $show_fines = $cgi->param('show_fines') // '0'; >+ if ( $show_fines eq '1' ) { > my @charges; > for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) { > push( @charges, @charge ); >@@ -403,7 +405,8 @@ sub GetPatronInfo { > } > > # Reserves management >- if ( $cgi->param('show_holds') eq "1" ) { >+ my $show_holds = $cgi->param('show_holds') // '0'; >+ if ( $show_holds eq '1' ) { > > # Get borrower's reserves > my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); >@@ -427,7 +430,8 @@ sub GetPatronInfo { > } > > # Issues management >- if ( $cgi->param('show_loans') eq "1" ) { >+ my $show_loans = $cgi->param('show_loans') // '0'; >+ if ( $show_loans eq '1' ) { > my $issues = GetPendingIssues($borrowernumber); > foreach my $issue ( @$issues ){ > $issue->{'issuedate'} = $issue->{'issuedate'}->strftime('%Y-%m-%d %H:%M'); >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index ee012e2..be343b4 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -3,10 +3,14 @@ > use Modern::Perl; > > use C4::Members qw/AddMember GetMember GetBorrowercategory/; >+use C4::Biblio qw( AddBiblio ); >+use C4::Items qw( AddItem ); >+use C4::Reserves qw( AddReserve GetReserve ); > use Koha::Libraries; > use CGI qw ( -utf8 ); >+use MARC::Record; > >-use Test::More tests => 16; >+use Test::More tests => 4; > use t::lib::Mocks; > use t::lib::TestBuilder; > >@@ -48,7 +52,8 @@ unless ( Koha::Libraries->find('UT') ) { > my $borrowernumber = AddMember(%data); > my $borrower = GetMember( borrowernumber => $borrowernumber ); > >-{ # AuthenticatePatron test >+subtest 'AuthenticatePatron' => sub { >+ plan tests => 14; > > my $query = new CGI; > $query->param('username',$borrower->{'userid'}); >@@ -89,8 +94,7 @@ my $borrower = GetMember( borrowernumber => $borrowernumber ); > $reply = C4::ILSDI::Services::AuthenticatePatron($query); > is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound"); > is($reply->{'id'}, undef, "id undef"); >- >-} >+}; > > # End transaction > $dbh->rollback; >@@ -109,7 +113,8 @@ $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this > $schema->resultset( 'Branch' )->delete_all; > > >-{ # GetPatronInfo/GetBorrowerAttributes test for extended patron attributes: >+subtest 'GetPatronInfo/GetBorrowerAttributes for extended patron attributes' => sub { >+ plan tests => 1; > > # Configure Koha to enable ILS-DI server and extended attributes: > t::lib::Mocks::mock_preference( 'ILS-DI', 1 ); >@@ -195,7 +200,60 @@ $schema->resultset( 'Branch' )->delete_all; > > # Check results: > is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' ); >-} >+}; >+ >+$schema->storage->txn_rollback; >+$schema->storage->txn_begin; >+ >+subtest 'GetRecords' => sub { >+ plan tests => 1; >+ >+ t::lib::Mocks::mock_preference('ILS-DI', 1); >+ >+ my $builder = t::lib::TestBuilder->new; >+ >+ my $branch = $builder->build({ >+ source => 'Branch', >+ value => { >+ branchcode => 'T_ILSDI', >+ } >+ }); >+ >+ my $category = $builder->build({ >+ source => 'Category', >+ value => { >+ category_type => 'A', >+ } >+ }); >+ >+ # Create a new user: >+ my $borrower = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode => $category->{categorycode}, >+ branchcode => $branch, >+ } >+ }); >+ >+ my ($biblionumber) = AddBiblio(MARC::Record->new, ''); >+ my $item = {}; >+ my $itemnumber = AddItem($item, $biblionumber); >+ >+ my $reserve_id = AddReserve($branch, $borrower->{borrowernumber}, $biblionumber); >+ >+ # Prepare and send web request for IL-SDI server: >+ my $query = new CGI; >+ $query->param( 'service', 'GetRecords' ); >+ $query->param( 'id', $biblionumber ); >+ >+ my $response = C4::ILSDI::Services::GetRecords( $query ); >+ >+ my $reserve = GetReserve($reserve_id); >+ $reserve->{rtimestamp} = $reserve->{timestamp}; >+ >+ is_deeply( $response->{record}->[0]->{reserves}->{reserve}, [ $reserve ], >+ 'GetRecords /record/reserves/reserve is as expected' ); >+}; > > # Cleanup > $schema->storage->txn_rollback; >-- >2.1.4
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 16246
:
50143
|
50144
|
56829
|
56830
|
61032
|
61033
|
61329
|
61330