Bugzilla – Attachment 65883 Details for
Bug 18624
Software error when searching authorities in Elasticsearch - incorrect parameter "any" should be "all"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18624: Regression test for 'any' vs 'all'
Bug-18624-Regression-test-for-any-vs-all.patch (text/plain), 3.30 KB, created by
Marcel de Rooy
on 2017-08-11 09:13:30 UTC
(
hide
)
Description:
Bug 18624: Regression test for 'any' vs 'all'
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-08-11 09:13:30 UTC
Size:
3.30 KB
patch
obsolete
>From 23e4b4756f4a7481b184b9c358b6a0e8ce86c4a2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 7 Aug 2017 16:09:56 -0300 >Subject: [PATCH] Bug 18624: Regression test for 'any' vs 'all' >Content-Type: text/plain; charset=utf-8 > >This test makes it explicit that the only string producing _all as index on build_authorities_query_compat is 'all'. >To test: >- Apply this patch >- Run: > $ sudo koha-shell kohadev > k$ cd kohaclone > k$ prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >=> FAIL: Test fails because the list of valid values is wrong in Koha. > >Note: this list has to be in sync with the templates passing the same values. A followup will be added >to fix a discrepancy found between OPAC and Intranet. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 57 ++++++++++++++++++++++ > 1 file changed, 57 insertions(+) > create mode 100644 t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >new file mode 100644 >index 0000000..a49b4b8 >--- /dev/null >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -0,0 +1,57 @@ >+#!/usr/bin/perl >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::Exception; >+ >+use Koha::Database; >+use Koha::SearchEngine::Elasticsearch::QueryBuilder; >+ >+subtest 'build_authorities_query_compat() tests' => sub { >+ >+ my $qb; >+ >+ ok( >+ $qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'authorities' }), >+ 'Creating new query builder object for authorities' >+ ); >+ >+ my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name; >+ my $search_term = 'a'; >+ >+ foreach my $koha_name ( keys %{ $koha_to_index_name } ) { >+ my $query = $qb->build_authorities_query_compat( [ $koha_name ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); >+ if ( $koha_name eq 'all' ) { >+ is( $query->{query}->{bool}->{should}[0]->{match}->{_all}, >+ $search_term); >+ } else { >+ is( $query->{query}->{bool}->{should}[0]->{match}->{$koha_to_index_name->{$koha_name}}, >+ $search_term); >+ } >+ } >+ >+ # Failing case >+ throws_ok { >+ $qb->build_authorities_query_compat( [ 'tomas' ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); >+ } >+ 'Koha::Exceptions::WrongParameter', >+ 'Exception thrown on invalid value in the marclist param'; >+}; >+ >+1; >-- >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 18624
:
64385
|
65591
|
65592
|
65593
|
65594
|
65882
| 65883 |
65884
|
65885
|
66020