Bugzilla – Attachment 60546 Details for
Bug 17941
CanBookBeRenewed is very inefficient/slow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17941 add tests to cover the optimization of the nested loop
Bug-17941-add-tests-to-cover-the-optimization-of-t.patch (text/plain), 5.07 KB, created by
Jonathan Druart
on 2017-02-22 11:08:37 UTC
(
hide
)
Description:
Bug 17941 add tests to cover the optimization of the nested loop
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-02-22 11:08:37 UTC
Size:
5.07 KB
patch
obsolete
>From 39b2ef42368e06b911a1750a95bdd1cf732b5108 Mon Sep 17 00:00:00 2001 >From: Francesco Rivetti <oha@oha.it> >Date: Mon, 20 Feb 2017 11:02:40 +0100 >Subject: [PATCH] Bug 17941 add tests to cover the optimization of the nested > loop > >the new code skip testing for more borrowers if the item can't be renewed >this require more tests for the case where 2+ items are reserved. > >I tried to add 1 more reserve to the main test suit, but too many other tests >rely on specific holds, and I couldn't get around it. > >Instead, I added a subtest that consider the specific simple case and leave the >other test cases exactly has they were designed. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Amended-patch: Just fix 3 indendations >--- > t/db_dependent/Circulation.t | 110 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 109 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index e3d4c8d..352abf8 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 91; >+use Test::More tests => 92; > > BEGIN { > require_ok('C4::Circulation'); >@@ -1249,6 +1249,114 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); > }; > >+subtest 'MultipleReserves' => sub { >+ plan tests => 3; >+ >+ my $biblio = MARC::Record->new(); >+ my $title = 'Silence in the library'; >+ $biblio->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), >+ MARC::Field->new('245', ' ', ' ', a => $title), >+ ); >+ >+ my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); >+ >+ my $branch = $library2->{branchcode}; >+ >+ my $barcode1 = 'R00110001'; >+ my ( $item_bibnum1, $item_bibitemnum1, $itemnumber1 ) = AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode1, >+ replacementprice => 12.00, >+ itype => $itemtype >+ }, >+ $biblionumber >+ ); >+ >+ my $barcode2 = 'R00110002'; >+ my ( $item_bibnum2, $item_bibitemnum2, $itemnumber2 ) = AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode2, >+ replacementprice => 12.00, >+ itype => $itemtype >+ }, >+ $biblionumber >+ ); >+ >+ my $bibitems = ''; >+ my $priority = '1'; >+ my $resdate = undef; >+ my $expdate = undef; >+ my $notes = ''; >+ my $checkitem = undef; >+ my $found = undef; >+ >+ my %renewing_borrower_data = ( >+ firstname => 'John', >+ surname => 'Renewal', >+ categorycode => 'S', >+ branchcode => $branch, >+ ); >+ my $renewing_borrowernumber = AddMember(%renewing_borrower_data); >+ my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber ); >+ my $issue = AddIssue( $renewing_borrower, $barcode1); >+ my $datedue = dt_from_string( $issue->date_due() ); >+ is (defined $issue->date_due(), 1, "item 1 checked out"); >+ my $borrowing_borrowernumber = GetItemIssue($itemnumber1)->{borrowernumber}; >+ >+ my %reserving_borrower_data1 = ( >+ firstname => 'Katrin', >+ surname => 'Reservation', >+ categorycode => 'S', >+ branchcode => $branch, >+ ); >+ my $reserving_borrowernumber1 = AddMember(%reserving_borrower_data1); >+ AddReserve( >+ $branch, $reserving_borrowernumber1, $biblionumber, >+ $bibitems, $priority, $resdate, $expdate, $notes, >+ $title, $checkitem, $found >+ ); >+ >+ my %reserving_borrower_data2 = ( >+ firstname => 'Kirk', >+ surname => 'Reservation', >+ categorycode => 'S', >+ branchcode => $branch, >+ ); >+ my $reserving_borrowernumber2 = AddMember(%reserving_borrower_data2); >+ AddReserve( >+ $branch, $reserving_borrowernumber2, $biblionumber, >+ $bibitems, $priority, $resdate, $expdate, $notes, >+ $title, $checkitem, $found >+ ); >+ >+ { >+ my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber1, 1); >+ is($renewokay, 0, 'Bug 17641 - should cover the case where 2 books are both reserved, so failing'); >+ } >+ >+ my $barcode3 = 'R00110003'; >+ my ( $item_bibnum3, $item_bibitemnum3, $itemnumber3 ) = AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode3, >+ replacementprice => 12.00, >+ itype => $itemtype >+ }, >+ $biblionumber >+ ); >+ >+ { >+ my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber1, 1); >+ is($renewokay, 1, 'Bug 17641 - should cover the case where 2 books are reserved, but a third one is available'); >+ } >+}; >+ > subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > plan tests => 5; > >-- >2.9.3
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 17941
:
59740
|
60181
|
60184
|
60185
|
60186
|
60188
|
60189
|
60190
|
60191
|
60192
|
60457
|
60472
|
60473
|
60474
|
60544
|
60545
| 60546