Bugzilla – Attachment 186390 Details for
Bug 21272
MARC import should warn about mis-matched branch during staged import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21272: (QA follow-up) Fix tidiness and unit test
Bug-21272-QA-follow-up-Fix-tidiness-and-unit-test.patch (text/plain), 7.16 KB, created by
Hammat wele
on 2025-09-12 21:43:57 UTC
(
hide
)
Description:
Bug 21272: (QA follow-up) Fix tidiness and unit test
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2025-09-12 21:43:57 UTC
Size:
7.16 KB
patch
obsolete
>From 63719e25ab63416cd5294b228bcee107a2504a5b Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Fri, 12 Sep 2025 21:19:07 +0000 >Subject: [PATCH] Bug 21272: (QA follow-up) Fix tidiness and unit test > >Signed-off-by: Hammat Wele <hammat.wele@inlibro.com> >--- > C4/ImportBatch.pm | 8 +++--- > .../en/modules/tools/manage-marc-import.tt | 11 ++++---- > t/db_dependent/ImportBatch.t | 26 ++++++++++++++----- > tools/manage-marc-import.pl | 4 +-- > 4 files changed, 32 insertions(+), 17 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index bfcae76643b..199377f4cc1 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -42,7 +42,7 @@ use Koha::SearchEngine::Indexer; > use Koha::Plugins::Handler; > use Koha::Logger; > use List::MoreUtils qw( uniq any ); >-use Array::Utils qw( array_minus ); >+use Array::Utils qw( array_minus ); > > our ( @ISA, @EXPORT_OK ); > >@@ -1287,7 +1287,7 @@ Returns an array of imported item branches. > =cut > > sub GetImportItemsBranches { >- my ( $batch_id ) = @_; >+ my ($batch_id) = @_; > > my $dbh = C4::Context->dbh; > my $query = "SELECT import_items_id, import_items.marcxml, encoding >@@ -1303,8 +1303,10 @@ sub GetImportItemsBranches { > my @branch; > my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField('items.homebranch'); > my ( $holdingbranchfield, $holdingbranchsubfield ) = GetMarcFromKohaField('items.holdingbranch'); >+ > foreach my $row (@$results) { >- my $item_marc = MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); >+ my $item_marc = >+ MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); > push @branch, $item_marc->subfield( $homebranchfield, $homebranchsubfield ); > push @branch, $item_marc->subfield( $holdingbranchfield, $holdingbranchsubfield ); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >index c558b956dfa..49c423eb53c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >@@ -258,11 +258,12 @@ > <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" /> > </fieldset> > [% IF ( missing_branches ) %] >- <div class="dialog alert"><span>One and more records contains incorrect library codes which are not part of your installation:</span> >+ <div class="dialog alert" >+ ><span>One and more records contains incorrect library codes which are not part of your installation:</span> > <span> >- [% FOREACH branche IN branches %] >- [% branche | html %] >- [% END %] >+ [% FOREACH branche IN branches %] >+ [% branche | html %] >+ [% END %] > </span> > </div> > [% END %] >@@ -272,7 +273,7 @@ > <span> > [% FOREACH title IN titles %] > [% title | html %] >- | >+ | > [% END %] > </span> > </div> >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index 55894c42b54..69d43f009ba 100755 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -1,6 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >+use Test::NoWarnings; > use Test::More tests => 23; > use utf8; > use File::Basename; >@@ -274,8 +275,11 @@ subtest "_batchCommitItems" => sub { > 'Error correctly set when import item has duplicate barcode and action always_add' > ); > >- $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => { >- marcxml => q{<?xml version="1.0" encoding="UTF-8"?> >+ $import_item = $builder->build_object( >+ { >+ class => 'Koha::Import::Record::Items', >+ value => { >+ marcxml => q{<?xml version="1.0" encoding="UTF-8"?> > <collection > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" >@@ -293,14 +297,22 @@ subtest "_batchCommitItems" => sub { > </record> > </collection> > }, >- }}); >+ } >+ } >+ ); > > ( $num_items_added, $num_items_replaced, $num_items_errored ) = >- C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add',64 ); >+ C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add', 64 ); > is( $num_items_errored, 1, "Item with wrong branchcode fails when action always_add" ); > $import_item->discard_changes(); >- is( $import_item->status, 'error', "Import item marked as error when wrong branchcode detected and action always_add"); >- is( $import_item->import_error, 'Branch code WBRC missing', 'Error correctly set when import item has a wrong branchcode detected and action always_add' ); >+ is( >+ $import_item->status, 'error', >+ "Import item marked as error when wrong branchcode detected and action always_add" >+ ); >+ is( >+ $import_item->import_error, 'Branch code WBRC missing', >+ 'Error correctly set when import item has a wrong branchcode detected and action always_add' >+ ); > }; > > subtest "RecordsFromMarcPlugin" => sub { >@@ -311,7 +323,7 @@ subtest "RecordsFromMarcPlugin" => sub { > if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { > print $fh q{ > 003 = NLAmRIJ >-100,a = 20220520d u||y0frey50 ba >+100,a = 20220520d u||y0frey50 by > 700,a = Author > 200,ind2 = 0 > 200,a = Silence in the library >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index 110e5bfb331..3cc0e40139f 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -37,7 +37,7 @@ use C4::Labels::Batch; > use Koha::BiblioFrameworks; > use Koha::BackgroundJob::MARCImportCommitBatch; > use Koha::BackgroundJob::MARCImportRevertBatch; >-use Array::Utils qw( array_minus ); >+use Array::Utils qw( array_minus ); > use List::MoreUtils qw( uniq any ); > > use Koha::Logger; >@@ -96,7 +96,7 @@ if ( $op eq "" ) { > import_batches_list( $template, $offset, $results_per_page ); > } else { > my @import_items_branches = GetImportItemsBranches($import_batch_id); >- my @import_items = GetBadBranchesImportItems($import_batch_id); >+ my @import_items = GetBadBranchesImportItems($import_batch_id); > my @bad_item_titles; > my @missing_branches; > foreach my $item (@import_items) { >-- >2.34.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 21272
:
155038
|
155039
|
155043
|
155523
|
155524
|
155525
|
158683
|
163646
|
163648
|
164143
|
164147
|
164148
|
164149
|
178921
|
178922
|
178923
|
178924
|
178925
|
178926
|
178927
|
178928
|
179837
|
179838
|
179839
|
179840
|
179841
|
179842
|
179843
|
179844
|
180383
|
180534
|
180535
|
180536
|
180537
|
180538
|
180539
|
180540
|
180541
|
180542
|
185334
|
185335
|
186389
| 186390