Bugzilla – Attachment 59012 Details for
Bug 17909
Add unit tests for authority merge
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 17909: Adding tests from bug 11315
SIGNED-OFF-Bug-17909-Adding-tests-from-bug-11315.patch (text/plain), 4.03 KB, created by
Josef Moravec
on 2017-01-16 13:05:16 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 17909: Adding tests from bug 11315
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-01-16 13:05:16 UTC
Size:
4.03 KB
patch
obsolete
>From ef7da7b7fe18a822bb45c8496e6253242d95cc1d Mon Sep 17 00:00:00 2001 >From: mbeaulieu <mbeaulieu@inlibro.com> >Date: Mon, 18 Aug 2014 10:04:55 -0400 >Subject: [PATCH] [SIGNED-OFF] Bug 17909: Adding tests from bug 11315 > >Based on original patch from Maxime Beaulieu on bug 11315. >Amended by Marcel de Rooy on report 17909. > >EDIT: > >Original tests have been adjusted in view of: >[1] Test on bug 11315 heavily leaned on DBD::Mock. Since we are > using Test::DBIx::Class on such tests now, this would need attention. > Moreover, the advantage of mocking the database in this case is at > least arguable. >[2] Matching the first (somewhat older) subtest of 11700. >[3] Simplification and readability. > Look e.g. at the use of $MARCto and $MARCfrom on 11315. > >This made me merge them in the db_dependent counterpart. > >Also note that this subtest adds another needed test case: the merge from >auth1 to modified auth1, while 11700 tested auth1 to auth2. > >Test plan: >Just run t/db_dependent/Authorities/Merge.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/db_dependent/Authorities/Merge.t | 42 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t >index a07fcd5..de9efab 100755 >--- a/t/db_dependent/Authorities/Merge.t >+++ b/t/db_dependent/Authorities/Merge.t >@@ -4,7 +4,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use MARC::Record; > use Test::MockModule; >@@ -77,6 +77,46 @@ subtest 'Test merge A1 to A2 (withing same authtype)' => sub { > 'Check biblio2 609$a' ); > }; > >+subtest 'Test merge A1 to modified A1' => sub { >+# Tests originate from bug 11700 >+ plan tests => 4; >+ >+ $dbh->do("INSERT IGNORE INTO marc_subfield_structure(tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES('109', 'a', 'Personal name', 'Personal name', 0, 0, '', 6, '', 'TEST_PERSO', '', NULL, 0, '', '', '', NULL)"); >+ $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'TEST_PERSO' WHERE tagfield='109' AND tagsubfield='a' AND frameworkcode='';"); >+ >+ my $auth1old = MARC::Record->new; >+ $auth1old->append_fields( MARC::Field->new( '109', '0', '0', 'a' => 'Bruce Wayne' )); >+ my $auth1new = $auth1old->clone; >+ $auth1new->field('109')->update( a => 'Batman' ); >+ my $authid1 = AddAuthority( $auth1new, undef, 'TEST_PERSO' ); >+ >+ my $MARC1 = MARC::Record->new(); >+ $MARC1->append_fields( MARC::Field->new( '245', '', '', 'a' => 'From the depths' )); >+ $MARC1->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Bruce Wayne', 'b' => '2014', '9' => $authid1 )); >+ my $MARC2 = MARC::Record->new(); >+ $MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' )); >+ $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 )); >+ my ( $biblionumber1 ) = AddBiblio( $MARC1, ''); >+ my ( $biblionumber2 ) = AddBiblio( $MARC2, ''); >+ >+ @zebrarecords = ( $MARC1, $MARC2 ); >+ $index = 0; >+ >+ my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new ); >+ is( $rv, 2, 'Both records are updated now' ); >+ >+ my $biblio1 = GetMarcBiblio($biblionumber1); >+ my $biblio2 = GetMarcBiblio($biblionumber1); >+ >+ my $auth_field = $auth1new->field(109)->subfield('a'); >+ is( $auth_field, $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' ); >+ is( $auth_field, $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' ); >+ >+ # TODO Following test will change when we improve merge >+ # Will depend on a preference >+ is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Record not overwritten while merging'); >+}; >+ > sub set_mocks { > # Mock ZOOM objects: They do nothing actually > # Get new_record_from_zebra to return the records >-- >2.1.4
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 17909
:
59005
|
59006
|
59007
|
59008
|
59011
|
59012
|
59013
|
59014
|
59015
|
59077
|
59088
|
59323
|
59324
|
59334
|
59335
|
59336
|
59337
|
59338
|
59339
|
59340