Bugzilla – Attachment 137606 Details for
Bug 29632
Callnumber sorting is incorrect in Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29632: Unit tests
Bug-29632-Unit-tests.patch (text/plain), 2.96 KB, created by
Martin Renvoize (ashimema)
on 2022-07-12 07:28:41 UTC
(
hide
)
Description:
Bug 29632: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-07-12 07:28:41 UTC
Size:
2.96 KB
patch
obsolete
>From c0820a3f22746d85e21e0a52f88cfee7eeef81fa Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 11 Jul 2022 15:56:05 +0000 >Subject: [PATCH] Bug 29632: Unit tests > >This patch adds unit tests, as well as changing existing test to use a mock >and read the data as passed in tests, rather than relying on what exists in >the DB > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../Koha/SearchEngine/Elasticsearch.t | 51 +++++++++++++++++-- > 1 file changed, 47 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t >index 51c1430942..0509328135 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t >@@ -128,14 +128,57 @@ subtest 'get_elasticsearch_settings() tests' => sub { > > subtest 'get_elasticsearch_mappings() tests' => sub { > >- plan tests => 1; >+ plan tests => 3; > > my $mappings; > >- # test reading mappings >- my $es = Koha::SearchEngine::Elasticsearch->new( {index => $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX} ); >- $mappings = $es->get_elasticsearch_mappings(); >+ my @mappings = ( >+ { >+ name => 'cn-sort', >+ type => 'callnumber', >+ facet => 0, >+ suggestible => 0, >+ searchable => 1, >+ sort => 1, >+ marc_type => 'marc21', >+ marc_field => '001', >+ }, >+ { >+ name => 'isbn', >+ type => 'string', >+ facet => 0, >+ suggestible => 0, >+ searchable => 1, >+ sort => 1, >+ marc_type => 'marc21', >+ marc_field => '020a', >+ }, >+ ); >+ my $search_engine_module = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); >+ $search_engine_module->mock('_foreach_mapping', sub { >+ my ($self, $sub) = @_; >+ >+ foreach my $map (@mappings) { >+ $sub->( >+ $map->{name}, >+ $map->{type}, >+ $map->{facet}, >+ $map->{suggestible}, >+ $map->{sort}, >+ $map->{searchable}, >+ $map->{marc_type}, >+ $map->{marc_field} >+ ); >+ } >+ }); >+ >+ my $search_engine_elasticsearch = Koha::SearchEngine::Elasticsearch::Search->new({ index => $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX }); >+ $mappings = $search_engine_elasticsearch->get_elasticsearch_mappings(); >+ >+ is( $mappings->{properties}{"cn-sort__sort"}{index}, 'false', 'Field mappings parsed correctly for sort for callnumber type' ); >+ is( $mappings->{properties}{"cn-sort__sort"}{numeric}, 'false', 'Field mappings parsed correctly for sort for callnumber type' ); > is( $mappings->{properties}{isbn__sort}{index}, 'false', 'Field mappings parsed correctly' ); >+ > }; > > subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { >-- >2.20.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 29632
:
136682
|
136754
|
137182
|
137539
|
137605
| 137606 |
137823
|
138611
|
139827