Bugzilla – Attachment 178927 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: Unit test for methods GetBadBranchesImportItems and GetTitleImportRecord
Bug-21272-Unit-test-for-methods-GetBadBranchesImpo.patch (text/plain), 5.12 KB, created by
Hammat wele
on 2025-03-04 15:17:43 UTC
(
hide
)
Description:
Bug 21272: Unit test for methods GetBadBranchesImportItems and GetTitleImportRecord
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2025-03-04 15:17:43 UTC
Size:
5.12 KB
patch
obsolete
>From 5053c95c266d499fe5d20c885d4007f97caeb7a2 Mon Sep 17 00:00:00 2001 >From: Matthias Le Gac <matthias.le-gac@inlibro.com> >Date: Fri, 29 Mar 2024 15:20:42 -0400 >Subject: [PATCH] Bug 21272: Unit test for methods GetBadBranchesImportItems > and GetTitleImportRecord > >--- > t/db_dependent/ImportBatch.t | 93 +++++++++++++++++++++++++++++++++++- > 1 file changed, 91 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index e1d47c5ec5..fd092cec41 100755 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 20; >+use Test::More tests => 22; > use utf8; > use File::Basename; > use File::Temp qw/tempfile/; >@@ -20,7 +20,7 @@ BEGIN { > use_ok('Koha::Plugins'); > use_ok( > 'C4::ImportBatch', >- qw( AddImportBatch GetImportBatch AddBiblioToBatch AddItemsToImportBiblio SetMatchedBiblionumber GetImportBiblios GetItemNumbersFromImportBatch CleanBatch DeleteBatch RecordsFromMarcPlugin BatchCommitRecords ) >+ qw( AddImportBatch GetImportBatch AddBiblioToBatch AddItemsToImportBiblio SetMatchedBiblionumber GetImportBiblios GetItemNumbersFromImportBatch CleanBatch DeleteBatch RecordsFromMarcPlugin BatchCommitRecords GetBadBranchesImportItems ) > ); > } > >@@ -203,6 +203,10 @@ $dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, $itemno ); > is( @a, 0, 'No item numbers expected since we deleted the item' ); > $dbh->do( $sql, undef, undef, $import_record_id ); # remove link again > >+# Test GetTitleImportRecord >+my $title_import_record = C4::ImportBatch::GetTitleImportRecord($import_record_id); >+is( $title_import_record, 'The art of computer programming', 'GetTitleImportRecord should return the correct title' ); >+ > # fresh data > my $sample_import_batch3 = { > matcher_id => 3, >@@ -431,6 +435,91 @@ subtest "BatchCommitRecords overlay into framework" => sub { > is( $biblio->frameworkcode, "QQ", "Framework set on overlay" ); > }; > >+subtest "GetBadBranchesImportItems" => sub { >+ plan tests => 2; >+ t::lib::Mocks::mock_config( 'enable_plugins', 0 ); >+ my $mock_import = Test::MockModule->new("C4::ImportBatch"); >+ my $biblio = $builder->build_sample_biblio; >+ $mock_import->mock( _get_commit_action => sub { return ( 'replace', 'ignore', $biblio->biblionumber ); } ); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $import_batch = { >+ matcher_id => 2, >+ template_id => 2, >+ branchcode => 'CTL', >+ overlay_action => 'replace', >+ nomatch_action => 'ignore', >+ item_action => 'ignore', >+ import_status => 'staged', >+ batch_type => 'z3950', >+ file_name => 'test.mrc', >+ comments => 'test', >+ record_type => 'auth', >+ }; >+ my $id_import_batch = C4::ImportBatch::AddImportBatch($import_batch); >+ my $import_record_id = AddBiblioToBatch( $id_import_batch, 0, $biblio->metadata->record, 'utf8', 0 ); >+ >+ my $import_item1 = $builder->build_object( >+ { >+ class => 'Koha::Import::Record::Items', >+ value => { >+ import_record_id => $import_record_id, >+ marcxml => qq{<?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" >+ xmlns="http://www.loc.gov/MARC21/slim"> >+ >+<record> >+ <leader>00000 a </leader> >+ <datafield tag="952" ind1=" " ind2=" "> >+ <subfield code="a">${\($library->branchcode)}</subfield> >+ <subfield code="b">${\($library->branchcode)}</subfield> >+ <subfield code="c">GEN</subfield> >+ <subfield code="p">test1234</subfield> >+ <subfield code="y">BK</subfield> >+ </datafield> >+</record> >+</collection> >+ }, >+ } >+ } >+ ); >+ >+ my @items = GetBadBranchesImportItems($id_import_batch); >+ is( scalar @items, 0, "No items with bad branchcode" ); >+ >+ my $import_item2 = $builder->build_object( >+ { >+ class => 'Koha::Import::Record::Items', >+ value => { >+ import_record_id => $import_record_id, >+ marcxml => qq{<?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" >+ xmlns="http://www.loc.gov/MARC21/slim"> >+ >+<record> >+ <leader>00000 a </leader> >+ <datafield tag="952" ind1=" " ind2=" "> >+ <subfield code="a">ABC</subfield> >+ <subfield code="b">ABC</subfield> >+ <subfield code="c">GEN</subfield> >+ <subfield code="p">test1234</subfield> >+ <subfield code="y">BK</subfield> >+ </datafield> >+</record> >+</collection> >+ }, >+ } >+ } >+ ); >+ >+ @items = GetBadBranchesImportItems($id_import_batch); >+ is( scalar @items, 2, "Items with bad branchcode" ); >+}; >+ > subtest "Do not adjust biblionumber when replacing items during import" => sub { > plan tests => 7; > >-- >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