Bugzilla – Attachment 123482 Details for
Bug 22690
Merging records with many items too slow (Elasticsearch)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22690: Add more tests
Bug-22690-Add-more-tests.patch (text/plain), 5.47 KB, created by
Martin Renvoize (ashimema)
on 2021-08-05 13:28:19 UTC
(
hide
)
Description:
Bug 22690: Add more tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-08-05 13:28:19 UTC
Size:
5.47 KB
patch
obsolete
>From 7a6fe96dc9066d5f00aead7a00c4c1ad11261f20 Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Mon, 9 Nov 2020 14:28:16 +0200 >Subject: [PATCH] Bug 22690: Add more tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >- Tests for adopt_items_from_biblio >- Tests for the relationship between items and acquisition orders >- Tests for indexer calls in adopt_items_from_biblio > >Signed-off-by: Michal Denar <black23@gmail.com> >Rebased-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Biblio.t | 24 +++++++++++- > t/db_dependent/Koha/Item.t | 43 +++++++++++++++++++++- > t/db_dependent/Koha/SearchEngine/Indexer.t | 10 ++++- > 3 files changed, 74 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index 83de0634c6..c978672aca 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 14; >+use Test::More tests => 15; > > use C4::Biblio qw( AddBiblio ModBiblio ); > use Koha::Database; >@@ -637,3 +637,25 @@ subtest 'get_marc_notes() UNIMARC tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'adopt_items_from_biblio() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ my $item1 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber }); >+ my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber }); >+ >+ $biblio2->adopt_items_from_biblio($biblio1); >+ >+ $item1->discard_changes; >+ $item2->discard_changes; >+ >+ is($item1->biblionumber, $biblio2->biblionumber, "Item 1 moved"); >+ is($item2->biblionumber, $biblio2->biblionumber, "Item 2 moved"); >+ >+ $schema->storage->txn_rollback; >+}; >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 15c89fc475..2080a93ad2 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -817,8 +817,49 @@ subtest 'get_transfers' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'move_to_biblio() tests' => sub { >+subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub { >+ plan tests => 2; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); >+ my $aq_budget = $builder->build({ >+ source => 'Aqbudget', >+ value => { >+ budget_notes => 'test', >+ }, >+ }); >+ >+ my $order_note = 'Order for ' . $item->itemnumber; >+ >+ my $aq_order1 = $builder->build_object({ >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ biblionumber => $biblio->biblionumber, >+ budget_id => $aq_budget->{budget_id}, >+ order_internalnote => $order_note, >+ }, >+ }); >+ my $aq_order2 = $builder->build_object({ >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ biblionumber => $biblio->biblionumber, >+ budget_id => $aq_budget->{budget_id}, >+ }, >+ }); >+ my $aq_order_item1 = $builder->build({ >+ source => 'AqordersItem', >+ value => { >+ ordernumber => $aq_order1->ordernumber, >+ itemnumber => $item->itemnumber, >+ }, >+ }); >+ >+ my $orders = $item->item_orders; >+ is ($orders->count, 1, 'One order found by item with the relationship'); >+ is ($orders->next->order_internalnote, $order_note, 'Correct order found by item with the relationship'); >+}; > >+subtest 'move_to_biblio() tests' => sub { > plan tests => 16; > > $schema->storage->txn_begin; >diff --git a/t/db_dependent/Koha/SearchEngine/Indexer.t b/t/db_dependent/Koha/SearchEngine/Indexer.t >index 8ecca94c29..278a4ed0e9 100755 >--- a/t/db_dependent/Koha/SearchEngine/Indexer.t >+++ b/t/db_dependent/Koha/SearchEngine/Indexer.t >@@ -61,7 +61,7 @@ subtest 'Test indexer object creation' => sub { > }; > > subtest 'Test indexer calls' => sub { >- plan tests => 44; >+ plan tests => 46; > > my @engines = ('Zebra'); > eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; >@@ -71,6 +71,8 @@ subtest 'Test indexer calls' => sub { > if scalar @engines == 1; > } > >+ t::lib::Mocks::mock_preference( 'BiblioAddsAuthorities', 0 ); >+ > for my $engine ( @engines ){ > t::lib::Mocks::mock_preference( 'SearchEngine', $engine ); > my $mock_index = Test::MockModule->new("Koha::SearchEngine::".$engine."::Indexer"); >@@ -170,6 +172,12 @@ subtest 'Test indexer calls' => sub { > $item4->move_to_biblio($biblio2, { skip_record_index => 1 }); > } undef, "index_records is not called for $engine when moving an item to another biblio (Item->move_to_biblio) if skip_record_index passed"; > >+ my $item5 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >+ my $item6 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >+ warnings_are{ >+ $biblio2->adopt_items_from_biblio($biblio); >+ } [$engine,"Koha::Biblio",$engine,"Koha::Biblio"], "index_records is called for both biblios for $engine when adopting items (Biblio->adopt_items_from_biblio)"; >+ > $builder->build({ > source => 'Issue', > value => { >-- >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 22690
:
90061
|
90115
|
90116
|
92828
|
94505
|
97696
|
98143
|
98210
|
98211
|
99376
|
99379
|
100316
|
104796
|
104797
|
104871
|
105445
|
106144
|
108777
|
109694
|
110991
|
110994
|
111196
|
111207
|
111236
|
111237
|
112100
|
112184
|
112567
|
112569
|
112754
|
113308
|
113309
|
113941
|
113942
|
113967
|
113968
|
118226
|
118227
|
118229
|
118231
|
118391
|
119433
|
119434
|
120820
|
120821
|
120852
|
120853
|
121389
|
121392
|
121474
|
121516
|
121517
|
121518
|
121519
|
121520
|
122846
|
122847
|
122848
|
122849
|
122850
|
122886
|
122887
|
122888
|
122889
|
122890
|
122936
|
122938
|
122939
|
123029
|
123030
|
123031
|
123032
|
123033
|
123034
|
123035
|
123036
|
123037
|
123038
|
123039
|
123040
|
123041
|
123042
|
123044
|
123062
|
123481
| 123482 |
123483
|
123484
|
123485
|
123486
|
123487
|
123488
|
123489
|
123490
|
123491
|
123492
|
123493
|
123494
|
123495
|
123496
|
123497
|
124176
|
124188
|
124257