|
Lines 21-26
use Test::More tests => 6;
Link Here
|
| 21 |
use Test::Exception; |
21 |
use Test::Exception; |
| 22 |
|
22 |
|
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
|
24 |
use t::lib::TestBuilder; |
| 24 |
|
25 |
|
| 25 |
use Test::MockModule; |
26 |
use Test::MockModule; |
| 26 |
|
27 |
|
|
Lines 31-36
use List::Util qw( any );
Link Here
|
| 31 |
use Koha::SearchEngine::Elasticsearch; |
32 |
use Koha::SearchEngine::Elasticsearch; |
| 32 |
use Koha::SearchEngine::Elasticsearch::Search; |
33 |
use Koha::SearchEngine::Elasticsearch::Search; |
| 33 |
|
34 |
|
|
|
35 |
my $schema = Koha::Database->new->schema; |
| 36 |
$schema->storage->txn_begin; |
| 37 |
|
| 34 |
subtest '_read_configuration() tests' => sub { |
38 |
subtest '_read_configuration() tests' => sub { |
| 35 |
|
39 |
|
| 36 |
plan tests => 10; |
40 |
plan tests => 10; |
|
Lines 336-342
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
| 336 |
MARC::Field->new('999', '', '', c => '1234568'), |
340 |
MARC::Field->new('999', '', '', c => '1234568'), |
| 337 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), |
341 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), |
| 338 |
); |
342 |
); |
| 339 |
my $records = [$marc_record_1, $marc_record_2]; |
343 |
my $records = [ |
|
|
344 |
{ record => $marc_record_1 }, |
| 345 |
{ record => $marc_record_2 }, |
| 346 |
]; |
| 340 |
|
347 |
|
| 341 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
348 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
| 342 |
|
349 |
|
|
Lines 503-509
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
| 503 |
$large_marc_record->append_fields($item_field); |
510 |
$large_marc_record->append_fields($item_field); |
| 504 |
} |
511 |
} |
| 505 |
|
512 |
|
| 506 |
$docs = $see->marc_records_to_documents([$large_marc_record]); |
513 |
$docs = $see->marc_records_to_documents([{ record => $large_marc_record }]); |
| 507 |
|
514 |
|
| 508 |
is($docs->[0]->{marc_format}, 'MARCXML', 'For record exceeding max record size marc_format should be set correctly'); |
515 |
is($docs->[0]->{marc_format}, 'MARCXML', 'For record exceeding max record size marc_format should be set correctly'); |
| 509 |
|
516 |
|
|
Lines 616-622
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t
Link Here
|
| 616 |
MARC::Field->new('999', '', '', c => '1234568'), |
623 |
MARC::Field->new('999', '', '', c => '1234568'), |
| 617 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'), |
624 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'), |
| 618 |
); |
625 |
); |
| 619 |
my $records = [$marc_record_1, $marc_record_2]; |
626 |
my $records = [ |
|
|
627 |
{ record => $marc_record_1 }, |
| 628 |
{ record => $marc_record_2 }, |
| 629 |
]; |
| 620 |
|
630 |
|
| 621 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
631 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
| 622 |
|
632 |
|
|
Lines 642-647
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori
Link Here
|
| 642 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
652 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
| 643 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
653 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
| 644 |
|
654 |
|
|
|
655 |
my $builder = t::lib::TestBuilder->new; |
| 656 |
my $auth_type = $builder->build_object({ class => 'Koha::Authority::Types', value =>{ |
| 657 |
auth_tag_to_report => '150' |
| 658 |
} |
| 659 |
}); |
| 660 |
|
| 645 |
my @mappings = ( |
661 |
my @mappings = ( |
| 646 |
{ |
662 |
{ |
| 647 |
name => 'match', |
663 |
name => 'match', |
|
Lines 652-708
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori
Link Here
|
| 652 |
sort => 0, |
668 |
sort => 0, |
| 653 |
marc_type => 'marc21', |
669 |
marc_type => 'marc21', |
| 654 |
marc_field => '150(ae)', |
670 |
marc_field => '150(ae)', |
| 655 |
}, |
671 |
} |
| 656 |
{ |
|
|
| 657 |
name => 'heading', |
| 658 |
type => 'string', |
| 659 |
facet => 0, |
| 660 |
suggestible => 0, |
| 661 |
searchable => 1, |
| 662 |
sort => 0, |
| 663 |
marc_type => 'marc21', |
| 664 |
marc_field => '150a', |
| 665 |
}, |
| 666 |
{ |
| 667 |
name => 'heading', |
| 668 |
type => 'string', |
| 669 |
facet => 0, |
| 670 |
suggestible => 0, |
| 671 |
searchable => 1, |
| 672 |
sort => 0, |
| 673 |
marc_type => 'marc21', |
| 674 |
marc_field => '150(ae)', |
| 675 |
}, |
| 676 |
{ |
| 677 |
name => 'heading-main', |
| 678 |
type => 'string', |
| 679 |
facet => 0, |
| 680 |
suggestible => 0, |
| 681 |
searchable => 1, |
| 682 |
sort => 0, |
| 683 |
marc_type => 'marc21', |
| 684 |
marc_field => '150a', |
| 685 |
}, |
| 686 |
{ |
| 687 |
name => 'heading', |
| 688 |
type => 'string', |
| 689 |
facet => 0, |
| 690 |
suggestible => 0, |
| 691 |
searchable => 1, |
| 692 |
sort => 0, |
| 693 |
marc_type => 'marc21', |
| 694 |
marc_field => '150', |
| 695 |
}, |
| 696 |
{ |
| 697 |
name => 'match-heading', |
| 698 |
type => 'string', |
| 699 |
facet => 0, |
| 700 |
suggestible => 0, |
| 701 |
searchable => 1, |
| 702 |
sort => 0, |
| 703 |
marc_type => 'marc21', |
| 704 |
marc_field => '150', |
| 705 |
}, |
| 706 |
); |
672 |
); |
| 707 |
|
673 |
|
| 708 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
674 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
|
Lines 735-741
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori
Link Here
|
| 735 |
$marc_record_2->append_fields( |
701 |
$marc_record_2->append_fields( |
| 736 |
MARC::Field->new('150', '', '', a => 'Subject', v => 'Genresubdiv', z => 'Geosubdiv', x => 'Generalsubdiv', e => 'wrongsubdiv' ), |
702 |
MARC::Field->new('150', '', '', a => 'Subject', v => 'Genresubdiv', z => 'Geosubdiv', x => 'Generalsubdiv', e => 'wrongsubdiv' ), |
| 737 |
); |
703 |
); |
| 738 |
my $records = [$marc_record_1, $marc_record_2]; |
704 |
my $records = [ |
|
|
705 |
{ record => $marc_record_1, authtypecode=> $auth_type->authtypecode }, |
| 706 |
{ record => $marc_record_2, authtypecode=> $auth_type->authtypecode }, |
| 707 |
]; |
| 739 |
|
708 |
|
| 740 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
709 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
| 741 |
|
710 |
|
|
Lines 752-754
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori
Link Here
|
| 752 |
"Second record match-heading should contain the correctly formatted heading without wrong subfield" |
721 |
"Second record match-heading should contain the correctly formatted heading without wrong subfield" |
| 753 |
); |
722 |
); |
| 754 |
}; |
723 |
}; |
| 755 |
- |
724 |
|
|
|
725 |
$schema->storage->txn_rollback; |