Bugzilla – Attachment 72400 Details for
Bug 14769
Authorities merge: Set correct indicators in biblio field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14769: Add tests for _thesaurus_info in ControlledIndicators.t
Bug-14769-Add-tests-for-thesaurusinfo-in-Controlle.patch (text/plain), 4.40 KB, created by
Josef Moravec
on 2018-03-05 07:01:07 UTC
(
hide
)
Description:
Bug 14769: Add tests for _thesaurus_info in ControlledIndicators.t
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-03-05 07:01:07 UTC
Size:
4.40 KB
patch
obsolete
>From c6ec9ca286d259f13df4f177f4b7c54bdc585a9e Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 6 Feb 2018 16:47:12 +0100 >Subject: [PATCH] Bug 14769: Add tests for _thesaurus_info in > ControlledIndicators.t > >Apart from adding tests for this sub, we make the following change >too and support it with a test. > >The fallback to $code in the construction > $thes_mapping{ $code } // $code // '4' >is removed by this patch. When $code is not in $thes_mapping, we cannot >assume that it is a valid code for a biblio indicator. In this case it is >more safe to mark it as 4 (Source not specified). > >Test plan: >Run t/Koha/Authority/ControlledIndicators.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/Authority/ControlledIndicators.pm | 2 +- > t/Koha/Authority/ControlledIndicators.t | 69 ++++++++++++++++++++++++++++++++- > 2 files changed, 69 insertions(+), 2 deletions(-) > >diff --git a/Koha/Authority/ControlledIndicators.pm b/Koha/Authority/ControlledIndicators.pm >index 87ae796..64a8734 100644 >--- a/Koha/Authority/ControlledIndicators.pm >+++ b/Koha/Authority/ControlledIndicators.pm >@@ -129,7 +129,7 @@ sub _thesaurus_info { > ? substr($record->field('008')->data, 11, 1) > : q{}; > my %thes_mapping = ( a => 0, b => 1, c => 2, d => 3, k => 5, n => 4, r => 7, s => 7, v => 6, z => 7, '|' => 4 ); >- my $ind = $thes_mapping{ $code } // $code // '4'; >+ my $ind = $thes_mapping{ $code } // '4'; > > # Determine optional subfield $2 > my $sub2; >diff --git a/t/Koha/Authority/ControlledIndicators.t b/t/Koha/Authority/ControlledIndicators.t >index 17ce49c..8552507 100644 >--- a/t/Koha/Authority/ControlledIndicators.t >+++ b/t/Koha/Authority/ControlledIndicators.t >@@ -4,7 +4,7 @@ use Modern::Perl; > use Data::Dumper qw/Dumper/; > use MARC::Record; > use MARC::Field; >-use Test::More tests => 1; >+use Test::More tests => 2; > > use t::lib::Mocks; > use Koha::Authority::ControlledIndicators; >@@ -71,3 +71,70 @@ marc21,800,ind1:, > }); > is_deeply( $res, {}, 'Cache cleared' ); > }; >+ >+subtest "Tests for sub _thesaurus_info" => sub { >+ plan tests => 10; >+ >+ t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q|marc21,600,ignored,ind2:thesaurus|); >+ my $oInd = Koha::Authority::ControlledIndicators->new; >+ >+ my $record = MARC::Record->new; >+ $record->append_fields( >+ MARC::Field->new( '008', (' 'x11).'a' ), >+ MARC::Field->new( '040', '', '', f => 'very_special' ), >+ ); >+ >+ # Case 1: LOC code a in auth record should become 0 in 6XX ind2 >+ my $res = $oInd->get({ >+ flavour => "MARC21", >+ report_tag => '100', >+ auth_record => $record, >+ biblio_tag => '600', >+ }); >+ is( $res->{ind2}, '0', 'Indicator matched for LOC headings' ); >+ is( $res->{sub2}, undef, 'No subfield 2' ); >+ >+ # Case 2: Code n (Not applicable) should become 4 (source not specified) >+ $record->field('008')->update( (' 'x11).'n' ); >+ $res = $oInd->get({ >+ flavour => "MARC21", >+ report_tag => '100', >+ auth_record => $record, >+ biblio_tag => '600', >+ }); >+ is( $res->{ind2}, '4', 'Source not specified' ); >+ is( $res->{sub2}, undef, 'No subfield 2' ); >+ >+ # Case 3: AAT thesaurus (and subfield $2) >+ $record->field('008')->update( (' 'x11).'r' ); >+ $res = $oInd->get({ >+ flavour => "MARC21", >+ report_tag => '100', >+ auth_record => $record, >+ biblio_tag => '600', >+ }); >+ is( $res->{ind2}, '7', 'AAT, see subfield 2' ); >+ is( $res->{sub2}, 'aat', 'Subfield 2 verified' ); >+ >+ # Case 4: Code z triggers a fetch from 040$f (and subfield $2) >+ $record->field('008')->update( (' 'x11).'z' ); >+ $res = $oInd->get({ >+ flavour => "MARC21", >+ report_tag => '100', >+ auth_record => $record, >+ biblio_tag => '600', >+ }); >+ is( $res->{ind2}, '7', 'Code z, see subfield 2' ); >+ is( $res->{sub2}, 'very_special', 'Subfield 2 from 040$f' ); >+ >+ # Case 5: Code e does not belong in 008/11 >+ $record->field('008')->update( (' 'x11).'e' ); >+ $res = $oInd->get({ >+ flavour => "MARC21", >+ report_tag => '100', >+ auth_record => $record, >+ biblio_tag => '600', >+ }); >+ is( $res->{ind2}, '4', 'Code e triggers not specified' ); >+ is( $res->{sub2}, undef, 'No subfield 2' ); >+}; >-- >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 14769
:
42197
|
69343
|
70948
|
70949
|
70950
|
70951
|
71338
|
71339
|
71340
|
71341
|
71342
|
71343
|
71351
|
71352
|
71353
|
71354
|
71355
|
71366
|
71374
|
71375
|
71376
|
71377
|
71378
|
71379
|
71380
|
71381
|
72398
|
72399
|
72400
|
72401
|
72402
|
72403
|
72404
|
73389
|
73773
|
73774
|
73775
|
73776
|
73777
|
73778
|
73779
|
74052