Bugzilla – Attachment 111878 Details for
Bug 26581
Elasticsearch - Records can be indexed multiple times during returns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26581: Unit tests
Bug-26581-Unit-tests.patch (text/plain), 5.60 KB, created by
Martin Renvoize (ashimema)
on 2020-10-16 14:07:35 UTC
(
hide
)
Description:
Bug 26581: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-10-16 14:07:35 UTC
Size:
5.60 KB
patch
obsolete
>From 560e60414c16e74662d2be3e0e5259889ce6cedb Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 30 Sep 2020 16:51:28 +0000 >Subject: [PATCH] Bug 26581: Unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >These tests cover the changes to ensure the AddReturn calls index_records once >per call and that other calls pass the skip_record_index parameter correctly > >Signed-off-by: Séverine Queune <severine.queune@bulac.fr> >Signed-off-by: Christoper Brannon <cbrannon@cdalibrary.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/SearchEngine/Indexer.t | 66 ++++++++++++++++++++-- > 1 file changed, 62 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Indexer.t b/t/db_dependent/Koha/SearchEngine/Indexer.t >index 4515d69f8d..997f6f17ca 100755 >--- a/t/db_dependent/Koha/SearchEngine/Indexer.t >+++ b/t/db_dependent/Koha/SearchEngine/Indexer.t >@@ -18,7 +18,9 @@ use t::lib::Mocks; > use C4::AuthoritiesMarc; > use C4::Biblio; > use C4::Circulation; >+use C4::Items; > use Koha::Database; >+use Koha::SearchEngine::Elasticsearch; > use Koha::SearchEngine::Indexer; > > use t::lib::TestBuilder; >@@ -58,13 +60,13 @@ subtest 'Test indexer object creation' => sub { > }; > > subtest 'Test indexer calls' => sub { >- plan tests => 24; >+ plan tests => 40; > > my @engines = ('Zebra'); > eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; > push @engines, 'Elasticsearch' unless $@; > SKIP: { >- skip 'Elasticsearch configuration not available', 12 >+ skip 'Elasticsearch configuration not available', 20 > if scalar @engines == 1; > } > >@@ -109,13 +111,53 @@ subtest 'Test indexer calls' => sub { > my $item; > my $item2; > warnings_are{ >- $item = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >- $item2 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >+ $item = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ onloan => '2020-02-02', >+ datelastseen => '2020-01-01' >+ }); >+ $item2 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ onloan => '2020-12-12', >+ datelastseen => '2020-11-11' >+ }); > } [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)"; > warnings_are{ > $item->store({ skip_record_index => 1 }); > } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed"; > >+ my $issue = $builder->build({ >+ source => 'Issue', >+ value => { >+ itemnumber => $item->itemnumber >+ } >+ }); >+ my $issue2 = $builder->build({ >+ source => 'Issue', >+ value => { >+ itemnumber => $item2->itemnumber >+ } >+ }); >+ warnings_are{ >+ MarkIssueReturned( $issue->{borrowernumber}, $item->itemnumber); >+ } [$engine,"Koha::Item"], "index_records is called for $engine when calling MarkIssueReturned"; >+ warnings_are{ >+ MarkIssueReturned( $issue2->{borrowernumber}, $item2->itemnumber, undef, undef, { skip_record_index => 1}); >+ } undef, "index_records is not called for $engine when calling MarkIssueReturned if skip_record_index passed"; >+ >+ warnings_are{ >+ AddReturn($item->barcode, $item->homebranch, 0, undef); >+ } [$engine,'C4::Circulation'], "index_records is called once for $engine when calling AddReturn if item not issued"; >+ $issue = $builder->build({ >+ source => 'Issue', >+ value => { >+ itemnumber => $item->itemnumber >+ } >+ }); >+ warnings_are{ >+ AddReturn($item->barcode, $item->homebranch, 0, undef); >+ } [$engine,'C4::Circulation'], "index_records is called once for $engine when calling AddReturn if item not issued"; >+ > $builder->build({ > source => 'Branchtransfer', > value => { >@@ -135,6 +177,22 @@ subtest 'Test indexer calls' => sub { > LostItem( $item->itemnumber, "tests", undef, { skip_record_index => 1 }); > } undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_record_index"; > >+ $item->datelastseen('2020-02-02'); >+ $item->store({skip_record_index=>1}); >+ warnings_are{ >+ my $t1 = ModDateLastSeen( $item->itemnumber, 1, undef ); >+ } [$engine, "Koha::Item"], "index_records is called for $engine when calling ModDateLastSeen"; >+ warnings_are{ >+ ModDateLastSeen( $item->itemnumber, 1, { skip_record_index =>1 } ); >+ } undef, "index_records is not called for $engine when calling ModDateLastSeen if skip_record_index"; >+ >+ warnings_are{ >+ ModItemTransfer( $item->itemnumber, $item->homebranch, $item2->homebranch,'Manual'); >+ } [$engine,"Koha::Item"], "index_records is called for $engine when calling ModItemTransfer"; >+ warnings_are{ >+ ModItemTransfer( $item->itemnumber, $item2->homebranch, $item->homebranch,'Manual',{skip_record_index=>1}); >+ } undef, "index_records is not called for $engine when calling ModItemTransfer with skip_record_index"; >+ > warnings_are{ > $item->delete(); > } [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)"; >-- >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 26581
:
111001
|
111002
|
111596
|
111597
| 111878 |
111879
|
112563
|
112578
|
112829