Bugzilla – Attachment 186345 Details for
Bug 24679
Allow to apply a MARC modification template in export tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24679: Fix exporter tests
Bug-24679-Fix-exporter-tests.patch (text/plain), 6.81 KB, created by
Aleisha Amohia
on 2025-09-10 23:53:17 UTC
(
hide
)
Description:
Bug 24679: Fix exporter tests
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2025-09-10 23:53:17 UTC
Size:
6.81 KB
patch
obsolete
>From d9c08273e34c6e8374e271eaedf636bc1a3d487d Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 13 Oct 2020 10:11:01 +0200 >Subject: [PATCH] Bug 24679: Fix exporter tests > >Tidy, and use 998 instead of 999 which is used in MARC21 to store biblionumber >--- > t/db_dependent/Exporter/Record.t | 84 ++++++++++++++++++-------------- > 1 file changed, 48 insertions(+), 36 deletions(-) > >diff --git a/t/db_dependent/Exporter/Record.t b/t/db_dependent/Exporter/Record.t >index 5d1cf83df97..6a01175d1b6 100755 >--- a/t/db_dependent/Exporter/Record.t >+++ b/t/db_dependent/Exporter/Record.t >@@ -438,28 +438,33 @@ subtest '_get_record_for_export MARC field conditions' => sub { > > subtest 'export csv with marc modification template' => sub { > plan tests => 1; >- my $csv_content = qq{Title=$title_field\$$title_subfield|Test=999\$9}; >- $dbh->do(q|INSERT INTO export_format(profile, description, content, csv_separator, field_separator, subfield_separator, encoding, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)|, {}, "TEST_PROFILE_Records.t", "my useless desc", $csv_content, '|', ';', ',', 'utf8', 'marc'); >+ my $csv_content = "Title=$title_field_tag\$a|Test=998\$9"; >+ $dbh->do( >+ q|INSERT INTO export_format(profile, description, content, csv_separator, field_separator, subfield_separator, encoding, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)|, >+ {}, "TEST_PROFILE_Records.t", "my useless desc", $csv_content, '|', ';', ',', 'utf8', 'marc' >+ ); > my $csv_profile_id = $dbh->last_insert_id( undef, undef, 'export_format', undef ); > > my $template_id = C4::MarcModificationTemplates::AddModificationTemplate('test exporter'); >- C4::MarcModificationTemplates::AddModificationTemplateAction($template_id, 'add_field', 0, '999', '9', 'Foobar'); >+ C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, 'add_field', 0, '998', '9', 'Foobar' ); > > my $generated_csv_file = '/tmp/test_export_1.csv'; >- Koha::Exporter::Record::export({ >- record_type => 'bibs', >- record_ids => [ $biblionumber_1 ], >- format => 'csv', >- csv_profile_id => $csv_profile_id, >- marc_modification_template_id => $template_id, >- output_filepath => $generated_csv_file, >- }); >+ Koha::Exporter::Record::export( >+ { >+ record_type => 'bibs', >+ record_ids => [$biblionumber_1], >+ format => 'csv', >+ csv_profile_id => $csv_profile_id, >+ marc_modification_template_id => $template_id, >+ output_filepath => $generated_csv_file, >+ } >+ ); > > my $expected_csv = <<EOF; > Title|Test > "$biblio_1_title"|Foobar > EOF >- my $generated_csv_content = read_file( $generated_csv_file ); >+ my $generated_csv_content = read_file($generated_csv_file); > is( $generated_csv_content, $expected_csv, "Export CSV: Modification template should have been applied" ); > }; > >@@ -467,18 +472,20 @@ subtest 'export xml with marc modification template' => sub { > plan tests => 2; > > my $template_id = C4::MarcModificationTemplates::AddModificationTemplate('test exporter'); >- C4::MarcModificationTemplates::AddModificationTemplateAction($template_id, 'add_field', 0, '999', '9', 'Foobar'); >+ C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, 'add_field', 0, '998', '9', 'Foobar' ); > > my $generated_xml_file = '/tmp/test_export.xml'; >- Koha::Exporter::Record::export({ >- record_type => 'bibs', >- record_ids => [ $biblionumber_1 ], >- format => 'xml', >- marc_modification_template_id => $template_id, >- output_filepath => $generated_xml_file, >- }); >- >- my $generated_xml_content = read_file( $generated_xml_file ); >+ Koha::Exporter::Record::export( >+ { >+ record_type => 'bibs', >+ record_ids => [$biblionumber_1], >+ format => 'xml', >+ marc_modification_template_id => $template_id, >+ output_filepath => $generated_xml_file, >+ } >+ ); >+ >+ my $generated_xml_content = read_file($generated_xml_file); > $MARC::File::XML::_load_args{BinaryEncoding} = 'utf-8'; > open my $fh, '<', $generated_xml_file; > my $records = MARC::Batch->new( 'XML', $fh ); >@@ -486,34 +493,39 @@ subtest 'export xml with marc modification template' => sub { > while ( my $record = $records->next ) { > push @records, $record; > } >- is( scalar( @records ), 1, 'Export XML: 1 record should have been exported' ); >+ is( scalar(@records), 1, 'Export XML: 1 record should have been exported' ); > my $record = $records[0]; >- is( $record->subfield('999', '9'), 'Foobar', 'Export XML: marc modification template should have added 999$9' ); >+ is( $record->subfield( '998', '9' ), 'Foobar', 'Export XML: marc modification template should have added 998$9' ); > }; > > subtest 'export iso2709 with marc modification template' => sub { > plan tests => 2; > > my $template_id = C4::MarcModificationTemplates::AddModificationTemplate('test exporter'); >- C4::MarcModificationTemplates::AddModificationTemplateAction($template_id, 'add_field', 0, '999', '9', 'Foobar'); >+ C4::MarcModificationTemplates::AddModificationTemplateAction( $template_id, 'add_field', 0, '998', '9', 'Foobar' ); > > my $generated_mrc_file = '/tmp/test_export.mrc'; >- Koha::Exporter::Record::export({ >- record_type => 'bibs', >- record_ids => [ $biblionumber_1 ], >- format => 'iso2709', >- marc_modification_template_id => $template_id, >- output_filepath => $generated_mrc_file, >- }); >- >- my $records = MARC::File::USMARC->in( $generated_mrc_file ); >+ Koha::Exporter::Record::export( >+ { >+ record_type => 'bibs', >+ record_ids => [$biblionumber_1], >+ format => 'iso2709', >+ marc_modification_template_id => $template_id, >+ output_filepath => $generated_mrc_file, >+ } >+ ); >+ >+ my $records = MARC::File::USMARC->in($generated_mrc_file); > my @records; > while ( my $record = $records->next ) { > push @records, $record; > } >- is( scalar( @records ), 1, 'Export ISO2709: 1 record should have been exported' ); >+ is( scalar(@records), 1, 'Export ISO2709: 1 record should have been exported' ); > my $record = $records[0]; >- is( $record->subfield('999', '9'), 'Foobar', 'Export ISO2709: marc modification template should have added 999$9' ); >+ is( >+ $record->subfield( '998', '9' ), 'Foobar', >+ 'Export ISO2709: marc modification template should have added 998$9' >+ ); > }; > > $schema->storage->txn_rollback; >-- >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 24679
:
99175
|
99304
|
99700
|
111519
|
111520
|
111521
|
186343
|
186344
| 186345