Bugzilla – Attachment 63480 Details for
Bug 18610
ElasticSearch indexing of facets needs to be updated for newer Catmandu versions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18610: regression tests
Bug-18610-regression-tests.patch (text/plain), 8.90 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-05-15 15:17:11 UTC
(
hide
)
Description:
Bug 18610: regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-05-15 15:17:11 UTC
Size:
8.90 KB
patch
obsolete
>From 56f5670bac582f79076ca611a542d8b79767aa49 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 15 May 2017 12:06:12 -0300 >Subject: [PATCH] Bug 18610: regression tests > >This patch introduces tests fr K::SE::ES::Indexer::_convert_marc_to_json >to test the facets that get extracted from the sample record. > >To test: >- Run > $ sudo koha-shell kohadev > k$ cd kohaclone > k$ prove t/db_dependent/Koha_Elasticsearch_Indexer.t \ > t/db_dependent/Koha_Elasticsearch.t >=> FAIL: Test fails because only last field mapped for facetting is considered (overwrite behaviour). > >Sponsored-by: ByWater Solutions >--- > t/db_dependent/Koha_Elasticsearch.t | 12 ++-- > t/db_dependent/Koha_Elasticsearch_Indexer.t | 86 ++++++++++++++++++++++++++++- > 2 files changed, 91 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/Koha_Elasticsearch.t b/t/db_dependent/Koha_Elasticsearch.t >index df76654..0b4b9cf 100644 >--- a/t/db_dependent/Koha_Elasticsearch.t >+++ b/t/db_dependent/Koha_Elasticsearch.t >@@ -79,11 +79,11 @@ subtest 'get_fixer_rules() tests' => sub { > > my $result = $see->get_fixer_rules(); > is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', -split => 1)}); >- is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet', -split => 1)}); >+ is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet.$append', -split => 1)}); > is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')}); > is( $result->[3], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', -split => 1)}); > is( $result->[4], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', -split => 1)}); >- is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet', -split => 1)}); >+ is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet.$append', -split => 1)}); > is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')}); > is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', -split => 1)}); > is( $result->[8], q{move_field(_id,es_id)}); >@@ -92,12 +92,12 @@ subtest 'get_fixer_rules() tests' => sub { > $mappings[1]->{type} = 'boolean'; > $result = $see->get_fixer_rules(); > is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', -split => 1)}); >- is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet', -split => 1)}); >+ is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet.$append', -split => 1)}); > is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')}); > is( $result->[3], q{unless exists('} . $mappings[0]->{name} . q{') add_field('} . $mappings[0]->{name} . q{', 0) end}); > is( $result->[4], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', -split => 1)}); > is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', -split => 1)}); >- is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet', -split => 1)}); >+ is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet.$append', -split => 1)}); > is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')}); > is( $result->[8], q{unless exists('} . $mappings[1]->{name} . q{') add_field('} . $mappings[1]->{name} . q{', 0) end}); > is( $result->[9], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', -split => 1)}); >@@ -107,12 +107,12 @@ subtest 'get_fixer_rules() tests' => sub { > $mappings[1]->{type} = 'sum'; > $result = $see->get_fixer_rules(); > is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', )}); >- is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet', )}); >+ is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet.$append', )}); > is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')}); > is( $result->[3], q{sum('} . $mappings[0]->{name} . q{')}); > is( $result->[4], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', )}); > is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', )}); >- is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet', )}); >+ is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet.$append', )}); > is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')}); > is( $result->[8], q{sum('} . $mappings[1]->{name} . q{')}); > is( $result->[9], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', )}); >diff --git a/t/db_dependent/Koha_Elasticsearch_Indexer.t b/t/db_dependent/Koha_Elasticsearch_Indexer.t >index e08d6c0..096ba83 100644 >--- a/t/db_dependent/Koha_Elasticsearch_Indexer.t >+++ b/t/db_dependent/Koha_Elasticsearch_Indexer.t >@@ -60,7 +60,7 @@ SKIP: { > > subtest '_convert_marc_to_json() tests' => sub { > >- plan tests => 2; >+ plan tests => 13; > > $schema->storage->txn_begin; > >@@ -117,9 +117,93 @@ subtest '_convert_marc_to_json() tests' => sub { > > my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' }); > my $conv = $importer->_convert_marc_to_json( \@records )->next(); >+ is( scalar @{$conv->{author}}, 2, q{Two authors indexed}); > is( $conv->{author}[0][0], "Author", "First mapped author should be 100a"); > is( $conv->{author}[1][0], "Corp Author", "Second mapped author should be 110a"); > >+ is( scalar @{$conv->{author__facet}}, 2, q{Two author facets}); >+ is( $conv->{author__facet}[0][0], "Author", "First mapped author facet should be 100a"); >+ is( $conv->{author__facet}[1][0], "Corp Author", "Second mapped author facet should be 110a"); >+ >+ @mappings = ( >+ { >+ name => 'author', >+ type => 'string', >+ facet => 1, >+ suggestible => 1, >+ sort => '~', >+ marc_type => 'marc21', >+ marc_field => '100a', >+ }, >+ { >+ name => 'author', >+ type => 'string', >+ facet => 0, >+ suggestible => 1, >+ sort => '~', >+ marc_type => 'marc21', >+ marc_field => '110a', >+ }, >+ ); >+ >+ $conv = $importer->_convert_marc_to_json( \@records )->next(); >+ >+ is( scalar @{$conv->{author__facet}}, 1, q{Only one author facet}); >+ is( $conv->{author__facet}[0][0], "Author", "Only author facet should be 100a"); >+ is( $conv->{author__facet}[1], undef, "No facet for 110a"); >+ >+ @mappings = ( >+ { >+ name => 'author', >+ type => 'string', >+ facet => 0, >+ suggestible => 1, >+ sort => '~', >+ marc_type => 'marc21', >+ marc_field => '100a', >+ }, >+ { >+ name => 'author', >+ type => 'string', >+ facet => 1, >+ suggestible => 1, >+ sort => '~', >+ marc_type => 'marc21', >+ marc_field => '110a', >+ }, >+ ); >+ >+ $conv = $importer->_convert_marc_to_json( \@records )->next(); >+ >+ is( scalar @{$conv->{author__facet}}, 1, q{Only one author facet}); >+ is( $conv->{author__facet}[0][0], "Corp Author", "Only author facet should be 110a"); >+ is( $conv->{author__facet}[1], undef, "No facet for 100a"); >+ >+ @mappings = ( >+ { >+ name => 'author', >+ type => 'string', >+ facet => 0, >+ suggestible => 1, >+ sort => '~', >+ marc_type => 'marc21', >+ marc_field => '100a', >+ }, >+ { >+ name => 'author', >+ type => 'string', >+ facet => 0, >+ suggestible => 1, >+ sort => '~', >+ marc_type => 'marc21', >+ marc_field => '110a', >+ }, >+ ); >+ >+ $conv = $importer->_convert_marc_to_json( \@records )->next(); >+ >+ is( $conv->{author__facet}, undef, q{No author facet}); >+ > $schema->storage->txn_rollback; > }; > >-- >2.7.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 18610
: 63480 |
63481