Bug 24480: Unit test
This updates the SimpleMARC tests and MarcModificationTemplates tests to expect the new order of fields Signed-off-by: Kelly <kelly@bywatersolutions.com> Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
d3112dc319
commit
48fd8d1900
|
|
@ -575,6 +575,13 @@ sub _copy_move_field {
|
|||
@from_fields = map { $_ <= @from_fields ? $from_fields[ $_ - 1 ] : () } @$field_numbers;
|
||||
}
|
||||
|
||||
if ( $action eq 'replace' ) {
|
||||
my @to_fields = $record->field( $toFieldName );
|
||||
for my $to_field ( @to_fields ) {
|
||||
$record->delete_field( $to_field );
|
||||
}
|
||||
}
|
||||
|
||||
for my $from_field ( @from_fields ) {
|
||||
my $new_field = $from_field->clone;
|
||||
$new_field->{_tag} = $toFieldName; # Should be replaced by set_tag, introduced by MARC::Field 2.0.4
|
||||
|
|
@ -588,12 +595,6 @@ sub _copy_move_field {
|
|||
if ( $action eq 'move' ) {
|
||||
$record->delete_field( $from_field )
|
||||
}
|
||||
elsif ( $action eq 'replace' ) {
|
||||
my @to_fields = $record->field( $toFieldName );
|
||||
if ( @to_fields ) {
|
||||
$record->delete_field( $to_fields[0] );
|
||||
}
|
||||
}
|
||||
$record->insert_grouped_field( $new_field );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'Computer programming.', 'Computer algorithms.' ],
|
||||
[ 'Computer algorithms.' , 'Computer programming.' ],
|
||||
'Copy multivalued field'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -447,7 +447,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'The art of programming.', 'The art of algorithms.' ],
|
||||
[ 'The art of algorithms.', 'The art of programming.' ],
|
||||
'Copy field using regex'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -466,7 +466,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'The mistake of programming.', 'The mistake of algorithms.' ],
|
||||
[ 'The mistake of algorithms.', 'The mistake of programming.' ],
|
||||
'Copy fields using regex on existing fields'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -485,7 +485,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'The art of programming.', 'The art of algorithms.', ],
|
||||
[ 'The art of algorithms.', 'The art of programming.', ],
|
||||
'Copy all fields using regex'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -533,7 +533,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '652', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_652a,
|
||||
[ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
|
||||
[ 'Cfoomputer algorithms.', 'Cfoomputer programming.' ],
|
||||
'Copy field using regex'
|
||||
);
|
||||
|
||||
|
|
@ -551,7 +551,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '653', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_653a,
|
||||
[ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
|
||||
[ 'Cfoomputer algfoorithms.', 'Cfoomputer prfoogramming.' ],
|
||||
'Copy field using regex'
|
||||
);
|
||||
|
||||
|
|
@ -569,7 +569,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '654', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_654a,
|
||||
[ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
|
||||
[ 'Cfoomputer algorithms.', 'Cfoomputer programming.' ],
|
||||
'Copy field using regex'
|
||||
);
|
||||
|
||||
|
|
@ -587,7 +587,7 @@ subtest 'copy_field' => sub {
|
|||
read_field( { record => $record, field => '655', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_655a,
|
||||
[ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
|
||||
[ 'Cfoomputer algfoorithms.', 'Cfoomputer prfoogramming.' ],
|
||||
'Copy field using regex'
|
||||
);
|
||||
|
||||
|
|
@ -981,7 +981,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'Computer programming.', 'Computer algorithms.' ],
|
||||
[ 'Computer algorithms.', 'Computer programming.' ],
|
||||
'Copy and replace multivalued field (same as copy)'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -1041,7 +1041,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'The art of programming.', 'The art of algorithms.' ],
|
||||
[ 'The art of algorithms.', 'The art of programming.' ],
|
||||
'Copy and replace field using regex (same as copy)'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -1060,7 +1060,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'The mistake of programming.', 'The mistake of algorithms.' ],
|
||||
[ 'The mistake of algorithms.', 'The mistake of programming.' ],
|
||||
'Copy and replace fields using regex on existing fields (same as copy)'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -1079,7 +1079,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '651', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_651a,
|
||||
[ 'The art of programming.', 'The art of algorithms.', ],
|
||||
[ 'The art of algorithms.', 'The art of programming.', ],
|
||||
'Copy and replace all fields using regex (same as copy)'
|
||||
);
|
||||
delete_field( { record => $record, field => '651' } );
|
||||
|
|
@ -1127,7 +1127,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '652', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_652a,
|
||||
[ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
|
||||
[ 'Cfoomputer algorithms.', 'Cfoomputer programming.' ],
|
||||
'Copy and replace field using regex (same as copy)'
|
||||
);
|
||||
|
||||
|
|
@ -1145,7 +1145,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '653', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_653a,
|
||||
[ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
|
||||
[ 'Cfoomputer algfoorithms.', 'Cfoomputer prfoogramming.' ],
|
||||
'Copy and replace field using regex (same as copy)'
|
||||
);
|
||||
|
||||
|
|
@ -1163,7 +1163,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '654', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_654a,
|
||||
[ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
|
||||
[ 'Cfoomputer algorithms.', 'Cfoomputer programming.' ],
|
||||
'Copy and replace field using regex (same as copy)'
|
||||
);
|
||||
|
||||
|
|
@ -1181,7 +1181,7 @@ subtest 'copy_and_replace_field' => sub {
|
|||
read_field( { record => $record, field => '655', subfield => 'a' } );
|
||||
is_deeply(
|
||||
\@fields_655a,
|
||||
[ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
|
||||
[ 'Cfoomputer algfoorithms.', 'Cfoomputer prfoogramming.' ],
|
||||
'Copy and replace field using regex (same as copy)'
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -507,6 +507,9 @@ sub expected_record_1 {
|
|||
my $record = MARC::Record->new;
|
||||
$record->leader('03174nam a2200445 a 4500');
|
||||
my @fields = (
|
||||
MARC::Field->new(
|
||||
'007', 'vxcdq',
|
||||
),
|
||||
MARC::Field->new(
|
||||
100, '1', ' ',
|
||||
a => 'Knuth, Donald Ervin',
|
||||
|
|
@ -517,10 +520,19 @@ sub expected_record_1 {
|
|||
a => 'The art of computer programming',
|
||||
c => 'Donald E. Knuth.',
|
||||
),
|
||||
MARC::Field->new(
|
||||
246, '', ' ',
|
||||
a => 'The art of computer programming',
|
||||
),
|
||||
MARC::Field->new(
|
||||
650, ' ', '0',
|
||||
9 => '462',
|
||||
),
|
||||
MARC::Field->new(
|
||||
651, ' ', '0',
|
||||
a => 'Computer algorithms.',
|
||||
9 => '499',
|
||||
),
|
||||
MARC::Field->new(
|
||||
952, ' ', ' ',
|
||||
p => '3010023917_updated',
|
||||
|
|
@ -528,25 +540,13 @@ sub expected_record_1 {
|
|||
c => 'GEN',
|
||||
e => '2001-06-25',
|
||||
),
|
||||
MARC::Field->new(
|
||||
246, '', ' ',
|
||||
a => 'The art of computer programming',
|
||||
),
|
||||
MARC::Field->new(
|
||||
651, ' ', '0',
|
||||
a => 'Computer algorithms.',
|
||||
9 => '499',
|
||||
),
|
||||
MARC::Field->new(
|
||||
999, ' ', ' ',
|
||||
a => 'existent - updated.',
|
||||
),
|
||||
MARC::Field->new(
|
||||
999, ' ', ' ',
|
||||
a => 'additional existent.',
|
||||
),
|
||||
MARC::Field->new(
|
||||
'007', 'vxcdq',
|
||||
999, ' ', ' ',
|
||||
a => 'existent - updated.',
|
||||
),
|
||||
);
|
||||
$record->append_fields(@fields);
|
||||
|
|
@ -577,18 +577,18 @@ sub expected_record_2 {
|
|||
a => 'Computer programming.',
|
||||
9 => '499',
|
||||
),
|
||||
MARC::Field->new(
|
||||
651, ' ', '0',
|
||||
a => 'Computer programming.',
|
||||
9 => '462',
|
||||
),
|
||||
MARC::Field->new(
|
||||
952, ' ', ' ',
|
||||
p => '3010023917',
|
||||
y => 'BK',
|
||||
c => 'GEN',
|
||||
d => '2001-06-25',
|
||||
),
|
||||
MARC::Field->new(
|
||||
651, ' ', '0',
|
||||
a => 'Computer programming.',
|
||||
9 => '462',
|
||||
),
|
||||
)
|
||||
);
|
||||
$record->append_fields(@fields);
|
||||
return $record;
|
||||
|
|
@ -720,6 +720,14 @@ sub expected_record_0 {
|
|||
a => 'The art of computer programming',
|
||||
c => 'Donald E. Knuth.',
|
||||
),
|
||||
MARC::Field->new(
|
||||
600, ' ', ' ',
|
||||
0 => 'TestUpdated',
|
||||
),
|
||||
MARC::Field->new(
|
||||
600, ' ', ' ',
|
||||
0 => 'TestUpdated',
|
||||
),
|
||||
MARC::Field->new(
|
||||
650, ' ', '0',
|
||||
0 => '42',
|
||||
|
|
@ -731,18 +739,6 @@ sub expected_record_0 {
|
|||
0 => 'Zeroth',
|
||||
a => 'Appolo',
|
||||
),
|
||||
MARC::Field->new(
|
||||
600, ' ', ' ',
|
||||
0 => 'TestUpdated',
|
||||
),
|
||||
MARC::Field->new(
|
||||
600, ' ', ' ',
|
||||
0 => 'TestUpdated',
|
||||
),
|
||||
MARC::Field->new(
|
||||
700, ' ', ' ',
|
||||
0 => '12345',
|
||||
),
|
||||
MARC::Field->new(
|
||||
690, ' ', ' ',
|
||||
0 => 'Zeroth',
|
||||
|
|
@ -753,6 +749,10 @@ sub expected_record_0 {
|
|||
0 => 'Zeroth',
|
||||
a => 'Appolo',
|
||||
),
|
||||
MARC::Field->new(
|
||||
700, ' ', ' ',
|
||||
0 => '12345',
|
||||
),
|
||||
);
|
||||
$record->append_fields(@fields);
|
||||
return $record;
|
||||
|
|
|
|||
Loading…
Reference in New Issue