Bugzilla – Attachment 175668 Details for
Bug 34739
Linked biblios should not be merged (updated) when changes to an authority don't change the authorized heading
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34739: Unit tests
Bug-34739-Unit-tests.patch (text/plain), 5.27 KB, created by
Roman Dolny
on 2024-12-18 19:04:49 UTC
(
hide
)
Description:
Bug 34739: Unit tests
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2024-12-18 19:04:49 UTC
Size:
5.27 KB
patch
obsolete
>From 434ac104396b4dcbf2ac6a6676a0d2a45736fcb1 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Wed, 18 Dec 2024 14:19:55 +0000 >Subject: [PATCH] Bug 34739: Unit tests > >BTW, there is a tiny adjustment to one of the previous subtests to >fit to the modified merge behaviour. > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > t/db_dependent/Authority/Merge.t | 90 +++++++++++++++++++++++++++++++- > 1 file changed, 88 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Authority/Merge.t b/t/db_dependent/Authority/Merge.t >index 2336cf999c..c2dafd5a27 100755 >--- a/t/db_dependent/Authority/Merge.t >+++ b/t/db_dependent/Authority/Merge.t >@@ -4,7 +4,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > > use Getopt::Long; > use MARC::Record; >@@ -147,7 +147,7 @@ subtest 'Test merge A1 to modified A1, test strict mode' => sub { > $MARC1->append_fields( MARC::Field->new( '609', '', '', 'a' => 'Bruce Lee', 'b' => 'Should be cleared too', '9' => $authid1 )); > $MARC1->append_fields( MARC::Field->new( '609', '', '', 'a' => 'Bruce Lee', 'c' => 'This is a duplicate to be removed in strict mode', '9' => $authid1 )); > my $MARC2 = MARC::Record->new; >- $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 )); >+ $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'BATMAN', '9' => $authid1 )); > $MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' )); > my ( $biblionumber1 ) = AddBiblio( $MARC1, ''); > my ( $biblionumber2 ) = AddBiblio( $MARC2, ''); >@@ -572,6 +572,92 @@ subtest "Test bibs not auto linked when merging" => sub { > > }; > >+ >+subtest 'ModBiblio calls from merge' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); >+ t::lib::Mocks::mock_preference( 'AuthorityControlledIndicators', '' ); >+ t::lib::Mocks::mock_preference( 'IncludeSeeFromInSearches', '1' ); >+ >+ my $auth_record = MARC::Record->new(); >+ $auth_record->insert_fields_ordered( MARC::Field->new( '109', '1', ' ', a => 'Brown,', 'c' => 'Father' ) ); >+ my $authid = AddAuthority( $auth_record, undef, $authtype1, { skip_record_index => 1 } ); >+ >+ my $auth_record_modified = $auth_record->clone; >+ $auth_record_modified->field('109')->update( c => 'Father (Fictitious character)' ); >+ >+ my $biblio_record = MARC::Record->new(); >+ $biblio_record->insert_fields_ordered( >+ MARC::Field->new( '609', '1', '1', a => 'Brown,', 'c' => 'Father', 9 => $authid ) ); >+ my $biblionumber = AddBiblio( $biblio_record, '', { skip_record_index => 1 } ); >+ >+ my $biblio_module = Test::MockModule->new('C4::AuthoritiesMarc'); >+ $biblio_module->mock( >+ 'ModBiblio', >+ sub { warn 'ModBiblio called'; } >+ ); >+ >+ warnings_are { >+ merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record_modified, >+ biblionumbers => [$biblionumber], >+ } >+ ); >+ } >+ ["ModBiblio called"], "real modification of bibliographic record, ModBiblio called"; >+ >+ t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); >+ my $mock_index = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Indexer'); >+ $mock_index->mock( 'index_records', sub { warn 'index_records called'; } ); >+ >+ warnings_are { >+ merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record, >+ biblionumbers => [$biblionumber], >+ } >+ ); >+ } >+ ["index_records called"], "no real modification of bibliographic record, index_records called"; >+ >+ t::lib::Mocks::mock_preference( 'IncludeSeeFromInSearches', '0' ); >+ t::lib::Mocks::mock_preference( 'IncludeSeeAlsoFromInSearches', '0' ); >+ warnings_are { >+ merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record, >+ biblionumbers => [$biblionumber], >+ } >+ ); >+ } >+ [], "no real modification of bibliographic record, index_records not called"; >+ >+ my $auth_record2 = MARC::Record->new(); >+ $auth_record2->insert_fields_ordered( MARC::Field->new( '109', '1', ' ', a => 'Chesterton, G.K.' ) ); >+ my $authid2 = AddAuthority( $auth_record2, undef, $authtype1, { skip_record_index => 1 } ); >+ >+ my $biblio_record2 = MARC::Record->new(); >+ $biblio_record2->insert_fields_ordered( >+ MARC::Field->new( '109', '1', ' ', a => 'Chesterton, G.K.', 9 => $authid2 ) ); >+ my $biblionumber2 = AddBiblio( $biblio_record2, '', { skip_record_index => 1 } ); >+ >+ my $num_biblio_edited = merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid2, MARCto => $auth_record2, >+ biblionumbers => [ $biblionumber, $biblionumber2 ], >+ } >+ ); >+ is( $num_biblio_edited, 1, 'Only one bibliographic record updated while merging two authorities' ); >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ > sub set_mocks { > # After we removed the Zebra code from merge, we only need to mock > # get_usage_count and linked_biblionumbers here. >-- >2.39.5
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 34739
:
175665
|
175666
|
175667
| 175668