|
Lines 17-22
use open ':std', ':encoding(utf8)';
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Test::More tests => 4; |
18 |
use Test::More tests => 4; |
| 19 |
use Test::MockModule; |
19 |
use Test::MockModule; |
|
|
20 |
use Test::Deep; |
| 20 |
use MARC::Record; |
21 |
use MARC::Record; |
| 21 |
use File::Spec; |
22 |
use File::Spec; |
| 22 |
use File::Basename; |
23 |
use File::Basename; |
|
Lines 349-356
sub run_marc21_search_tests {
Link Here
|
| 349 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[1] && |
350 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[1] && |
| 350 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[2] && |
351 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[2] && |
| 351 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[3] && |
352 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[3] && |
| 352 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[4] && |
353 |
!defined $results_hashref->{biblioserver}->{RECORDS}->[4], |
| 353 |
$results_hashref->{biblioserver}->{RECORDS}->[5] eq $record5, "getRecords cursor works"); |
354 |
"getRecords cursor works (undef first 5 results)"); |
|
|
355 |
cmp_deeply( $results_hashref->{biblioserver}->{RECORDS}->[5], |
| 356 |
$record5, "getRecords cursor works"); |
| 354 |
|
357 |
|
| 355 |
( undef, $results_hashref, $facets_loop ) = |
358 |
( undef, $results_hashref, $facets_loop ) = |
| 356 |
getRecords('ti:book', 'ti:book', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
359 |
getRecords('ti:book', 'ti:book', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
|
Lines 360-441
sub run_marc21_search_tests {
Link Here
|
| 360 |
getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
363 |
getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 361 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records"); |
364 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records"); |
| 362 |
|
365 |
|
| 363 |
if ( $indexing_mode eq 'dom' ) { |
|
|
| 364 |
( undef, $results_hashref, $facets_loop ) = |
366 |
( undef, $results_hashref, $facets_loop ) = |
| 365 |
getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
367 |
getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 366 |
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Efectos del ambiente/ && |
368 |
ok($results_hashref->{biblioserver}->{RECORDS}->[0]->title_proper() =~ m/^Efectos del ambiente/ && |
| 367 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' && |
369 |
$results_hashref->{biblioserver}->{RECORDS}->[7]->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' && |
| 368 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ |
370 |
$results_hashref->{biblioserver}->{RECORDS}->[18]->title_proper() =~ m/^Indicadores de resultados identificados/ |
| 369 |
, "Simple relevance sorting in getRecords matches old behavior"); |
371 |
, "Simple relevance sorting in getRecords matches old behavior"); |
| 370 |
|
372 |
|
| 371 |
( undef, $results_hashref, $facets_loop ) = |
373 |
( undef, $results_hashref, $facets_loop ) = |
| 372 |
getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
374 |
getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 373 |
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ && |
375 |
ok($results_hashref->{biblioserver}->{RECORDS}->[0]->title_proper() =~ m/la enfermedad laboral\^ies$/ && |
| 374 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[6],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ && |
376 |
$results_hashref->{biblioserver}->{RECORDS}->[6]->title_proper() =~ m/^Indicadores de resultados identificados/ && |
| 375 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' |
377 |
$results_hashref->{biblioserver}->{RECORDS}->[18]->title_proper() eq 'World health statistics 2009^ien' |
| 376 |
, "Simple ascending author sorting in getRecords matches old behavior"); |
378 |
, "Simple ascending author sorting in getRecords matches old behavior"); |
| 377 |
|
379 |
|
| 378 |
( undef, $results_hashref, $facets_loop ) = |
380 |
( undef, $results_hashref, $facets_loop ) = |
| 379 |
getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
381 |
getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 380 |
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' && |
382 |
ok($results_hashref->{biblioserver}->{RECORDS}->[0]->title_proper() eq 'World health statistics 2009^ien' && |
| 381 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[12],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ && |
383 |
$results_hashref->{biblioserver}->{RECORDS}->[12]->title_proper() =~ m/^Indicadores de resultados identificados/ && |
| 382 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ |
384 |
$results_hashref->{biblioserver}->{RECORDS}->[18]->title_proper() =~ m/la enfermedad laboral\^ies$/ |
| 383 |
, "Simple descending author sorting in getRecords matches old behavior"); |
385 |
, "Simple descending author sorting in getRecords matches old behavior"); |
| 384 |
|
386 |
|
| 385 |
( undef, $results_hashref, $facets_loop ) = |
387 |
( undef, $results_hashref, $facets_loop ) = |
| 386 |
getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
388 |
getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 387 |
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' && |
389 |
ok($results_hashref->{biblioserver}->{RECORDS}->[0]->title_proper() eq 'Manual de higiene industrial^ies' && |
| 388 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ && |
390 |
$results_hashref->{biblioserver}->{RECORDS}->[7]->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ && |
| 389 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ |
391 |
$results_hashref->{biblioserver}->{RECORDS}->[18]->title_proper() =~ m/^Indicadores de resultados identificados/ |
| 390 |
, "Simple ascending publication date sorting in getRecords matches old behavior"); |
392 |
, "Simple ascending publication date sorting in getRecords matches old behavior"); |
| 391 |
|
393 |
|
| 392 |
( undef, $results_hashref, $facets_loop ) = |
394 |
( undef, $results_hashref, $facets_loop ) = |
| 393 |
getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
395 |
getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 394 |
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Estado de salud/ && |
396 |
ok($results_hashref->{biblioserver}->{RECORDS}->[0]->title_proper() =~ m/^Estado de salud/ && |
| 395 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' && |
397 |
$results_hashref->{biblioserver}->{RECORDS}->[7]->title_proper() eq 'World health statistics 2009^ien' && |
| 396 |
MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' |
398 |
$results_hashref->{biblioserver}->{RECORDS}->[18]->title_proper() eq 'Manual de higiene industrial^ies' |
| 397 |
, "Simple descending publication date sorting in getRecords matches old behavior"); |
399 |
, "Simple descending publication date sorting in getRecords matches old behavior"); |
| 398 |
|
400 |
|
| 399 |
} elsif ( $indexing_mode eq 'grs1' ){ |
|
|
| 400 |
( undef, $results_hashref, $facets_loop ) = |
| 401 |
getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 402 |
ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/^Efectos del ambiente/ && |
| 403 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' && |
| 404 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() =~ m/^Indicadores de resultados identificados/ |
| 405 |
, "Simple relevance sorting in getRecords matches old behavior"); |
| 406 |
|
| 407 |
( undef, $results_hashref, $facets_loop ) = |
| 408 |
getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 409 |
ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/la enfermedad laboral\^ies$/ && |
| 410 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[6])->title_proper() =~ m/^Indicadores de resultados identificados/ && |
| 411 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() eq 'World health statistics 2009^ien' |
| 412 |
, "Simple ascending author sorting in getRecords matches old behavior"); |
| 413 |
|
| 414 |
( undef, $results_hashref, $facets_loop ) = |
| 415 |
getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 416 |
ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() eq 'World health statistics 2009^ien' && |
| 417 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[12])->title_proper() =~ m/^Indicadores de resultados identificados/ && |
| 418 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() =~ m/la enfermedad laboral\^ies$/ |
| 419 |
, "Simple descending author sorting in getRecords matches old behavior"); |
| 420 |
|
| 421 |
( undef, $results_hashref, $facets_loop ) = |
| 422 |
getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 423 |
ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() eq 'Manual de higiene industrial^ies' && |
| 424 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ && |
| 425 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() =~ m/^Indicadores de resultados identificados/ |
| 426 |
, "Simple ascending publication date sorting in getRecords matches old behavior"); |
| 427 |
|
| 428 |
( undef, $results_hashref, $facets_loop ) = |
| 429 |
getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); |
| 430 |
ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/^Estado de salud/ && |
| 431 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() eq 'World health statistics 2009^ien' && |
| 432 |
MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() eq 'Manual de higiene industrial^ies' |
| 433 |
, "Simple descending publication date sorting in getRecords matches old behavior"); |
| 434 |
} |
| 435 |
|
401 |
|
| 436 |
( undef, $results_hashref, $facets_loop ) = |
402 |
( undef, $results_hashref, $facets_loop ) = |
| 437 |
getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1); |
403 |
getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1); |
| 438 |
$record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]); |
404 |
$record = $results_hashref->{biblioserver}->{RECORDS}->[0]; |
| 439 |
is($record->title_proper(), 'Books', "Scan returned requested item"); |
405 |
is($record->title_proper(), 'Books', "Scan returned requested item"); |
| 440 |
is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term"); |
406 |
is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term"); |
| 441 |
# Time to test buildQuery and searchResults too. |
407 |
# Time to test buildQuery and searchResults too. |
|
Lines 578-589
if ( $indexing_mode eq 'dom' ) {
Link Here
|
| 578 |
|
544 |
|
| 579 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
545 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
| 580 |
is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results"); |
546 |
is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results"); |
| 581 |
if ($indexing_mode eq 'grs1') { |
547 |
is($results_hashref->{biblioserver}->{RECORDS}->[0]->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first"); |
| 582 |
is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first"); |
|
|
| 583 |
} else { |
| 584 |
local $TODO = "Query weighting does not behave exactly the same in DOM vs. GRS"; |
| 585 |
is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first"); |
| 586 |
} |
| 587 |
|
548 |
|
| 588 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0; |
549 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0; |
| 589 |
$QueryAutoTruncate = 1; |
550 |
$QueryAutoTruncate = 1; |
|
Lines 914-925
sub run_unimarc_search_tests {
Link Here
|
| 914 |
} |
875 |
} |
| 915 |
|
876 |
|
| 916 |
subtest 'MARC21 + GRS-1' => sub { |
877 |
subtest 'MARC21 + GRS-1' => sub { |
| 917 |
plan tests => 104; |
878 |
plan tests => 105; |
| 918 |
run_marc21_search_tests('grs1'); |
879 |
run_marc21_search_tests('grs1'); |
| 919 |
}; |
880 |
}; |
| 920 |
|
881 |
|
| 921 |
subtest 'MARC21 + DOM' => sub { |
882 |
subtest 'MARC21 + DOM' => sub { |
| 922 |
plan tests => 104; |
883 |
plan tests => 105; |
| 923 |
run_marc21_search_tests('dom'); |
884 |
run_marc21_search_tests('dom'); |
| 924 |
}; |
885 |
}; |
| 925 |
|
886 |
|
| 926 |
- |
|
|