Bugzilla – Attachment 140046 Details for
Bug 30280
Support authority records with common subject headings from different thesaurus
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30280: Add Unit tests
Bug-30280-Add-Unit-tests.patch (text/plain), 5.29 KB, created by
Frank Hansen
on 2022-09-01 14:13:55 UTC
(
hide
)
Description:
Bug 30280: Add Unit tests
Filename:
MIME Type:
Creator:
Frank Hansen
Created:
2022-09-01 14:13:55 UTC
Size:
5.29 KB
patch
obsolete
>From 6ad252582e0be615a1dfb3bc7b8c5b6245296744 Mon Sep 17 00:00:00 2001 >From: Frank Hansen <frank.hansen@ub.lu.se> >Date: Thu, 1 Sep 2022 13:57:13 +0000 >Subject: [PATCH] Bug 30280: Add Unit tests > >Sponsored-by: Lund University Library, Sweden >--- > .../SearchEngine/Elasticsearch/QueryBuilder.t | 5 ++- > t/db_dependent/Linker_Default.t | 34 +++++++++++++++++-- > 2 files changed, 35 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index b11c667e4a..9bf2ce037f 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -54,6 +54,9 @@ $se->mock( 'get_elasticsearch_mappings', sub { > type => 'text', > facet => 1 > }, >+ 'subject-heading-thesaurus-conventions' => { >+ type => 'text' >+ }, > itemnumber => { > type => 'integer' > }, >@@ -101,7 +104,7 @@ $se->mock( 'get_elasticsearch_mappings', sub { > > subtest 'build_authorities_query_compat() tests' => sub { > >- plan tests => 65; >+ plan tests => 72; > > my $qb; > >diff --git a/t/db_dependent/Linker_Default.t b/t/db_dependent/Linker_Default.t >index e16d790298..0141d9a2af 100755 >--- a/t/db_dependent/Linker_Default.t >+++ b/t/db_dependent/Linker_Default.t >@@ -42,16 +42,26 @@ my $schema = $builder->schema(); > $schema->storage->txn_begin; > > subtest 'Test caching in get_link and update_cache' => sub { >- plan tests => 6; >+ plan tests => 13; > > my @tags = C4::Context->preference('marcflavour') eq 'UNIMARC' ? (601,'j',602,'a') : (650,'a',655,'a'); > > my $subject_field = MARC::Field->new($tags[0],0,2,$tags[1]=>'Science fiction'); > my $subject_field2 = MARC::Field->new($tags[0],0,2,$tags[1]=>'Science fiction'); >+ my $subject_field3 = MARC::Field->new($tags[0],0,0,$tags[1]=>'Science fiction'); >+ my $subject_field4 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'bnb'); >+ my $subject_field5 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao'); >+ my $subject_field6 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao'); >+ my $subject_field7 = MARC::Field->new($tags[0],0,4,$tags[1]=>'Science fiction'); > my $genre_field = MARC::Field->new($tags[2],0,2,$tags[3]=>'Science fiction'); > # Can we build a heading from it? > my $subject_heading = C4::Heading->new_from_field( $subject_field, q{} ); >- my $subject_heading2 = C4::Heading->new_from_field( $subject_field, q{} ); >+ my $subject_heading2 = C4::Heading->new_from_field( $subject_field2, q{} ); >+ my $subject_heading3 = C4::Heading->new_from_field( $subject_field3, q{} ); >+ my $subject_heading4 = C4::Heading->new_from_field( $subject_field4, q{} ); >+ my $subject_heading5 = C4::Heading->new_from_field( $subject_field5, q{} ); >+ my $subject_heading6 = C4::Heading->new_from_field( $subject_field6, q{} ); >+ my $subject_heading7 = C4::Heading->new_from_field( $subject_field7, q{} ); > my $genre_heading = C4::Heading->new_from_field( $genre_field, q{} ); > > >@@ -67,13 +77,31 @@ subtest 'Test caching in get_link and update_cache' => sub { > $linker->get_link($subject_heading2); > is( keys %{$linker->{cache}},2, "Third (matching) term not added to cache because of matching type"); > >+ $linker->get_link($subject_heading3); >+ is( keys %{$linker->{cache}},3, "Fourth (matching) term added to cache because of different thesaurus (lcsh)"); >+ >+ $linker->get_link($subject_heading4); >+ is( keys %{$linker->{cache}},4, "Fifth (matching) term added to cache because of different thesaurus (bnb)"); >+ >+ $linker->get_link($subject_heading5); >+ is( keys %{$linker->{cache}},5, "Sixth (matching) term added to cache because of different thesaurus (sao)"); >+ >+ $linker->get_link($subject_heading6); >+ is( keys %{$linker->{cache}},5, "Seventh (matching) term not added to cache because of matching type and thesaurus (sao)"); >+ >+ $linker->get_link($subject_heading7); >+ is( keys %{$linker->{cache}},6, "Eigth (matching) term added to cache because of thesaurus source not specified (2nd indicator is 4)"); > > $linker->update_cache($subject_heading,32); >- is( $linker->{cache}->{$subject_heading->search_form.$subject_heading->auth_type}->{authid}, 32, "Linker cache is correctly updated by 'update_cache'"); >+ is( $linker->{cache}->{$subject_heading->search_form.$subject_heading->auth_type.$subject_heading->{'thesaurus'}}->{authid}, 32, "Linker cache is correctly updated by 'update_cache'"); > my ( $authid, undef ) = $linker->get_link($subject_heading); > is( $authid, 32, "Correct id is retrieved from the cache" ); > ( $authid, undef ) = $linker->get_link($genre_heading); > isnt( $authid, 32, "Genre term is not updated by update_cache"); >+ ( $authid, undef ) = $linker->get_link($subject_heading5); >+ is( $authid, 4, "Correct id for sao term is retrieved from the cache" ); >+ $linker->update_cache($subject_heading4,78); >+ is( $linker->{cache}->{$subject_heading4->search_form.$subject_heading4->auth_type.$subject_heading4->{'thesaurus'}}->{authid}, 78, "Linker cache for the bnb record is correctly updated by 'update_cache'"); > }; > > $schema->storage->txn_rollback; >-- >2.30.2
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 30280
:
131753
|
131754
|
131755
|
131756
|
131766
|
131767
|
131768
|
131769
|
131770
|
131771
|
131772
|
131773
|
131774
|
137440
|
137818
|
137819
|
137820
|
137890
|
137891
|
137892
|
137897
|
137898
|
137899
|
137900
|
137901
|
137902
|
139854
|
139855
|
139856
|
140040
|
140041
|
140042
|
140044
|
140045
|
140046
|
140284
|
140285
|
140286
|
140287