Bugzilla – Attachment 91740 Details for
Bug 13937
Add an Elasticsearch-compatible Z39.50/SRU daemon
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13937: Add SRU tests
Bug-13937-Add-SRU-tests.patch (text/plain), 6.19 KB, created by
Ere Maijala
on 2019-07-23 12:30:53 UTC
(
hide
)
Description:
Bug 13937: Add SRU tests
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2019-07-23 12:30:53 UTC
Size:
6.19 KB
patch
obsolete
>From dd4eb9a58f57b2e184d78a997e70ad21a0f1e3b7 Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Tue, 23 Jul 2019 15:14:51 +0300 >Subject: [PATCH] Bug 13937: Add SRU tests > >--- > .../Koha/Z3950Responder/GenericSession.t | 56 +++++++++++++++---- > t/db_dependent/Koha/Z3950Responder/config.xml | 13 +++++ > 2 files changed, 58 insertions(+), 11 deletions(-) > create mode 100644 t/db_dependent/Koha/Z3950Responder/config.xml > >diff --git a/t/db_dependent/Koha/Z3950Responder/GenericSession.t b/t/db_dependent/Koha/Z3950Responder/GenericSession.t >index ee77d0286c..1dcf69fa60 100644 >--- a/t/db_dependent/Koha/Z3950Responder/GenericSession.t >+++ b/t/db_dependent/Koha/Z3950Responder/GenericSession.t >@@ -3,8 +3,11 @@ > use Modern::Perl; > > use Test::More tests => 3; >+use Test::WWW::Mechanize; > use t::lib::Mocks qw(mock_preference); > >+use File::Basename; >+use XML::LibXML; > use YAML; > use ZOOM; > >@@ -17,7 +20,7 @@ our $child; > > subtest 'test_search' => sub { > >- plan tests => 9; >+ plan tests => 20; > > t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); > >@@ -51,7 +54,8 @@ subtest 'test_search' => sub { > biblios => { > use => { > 1 => 'author', >- 4 => 'title' >+ 4 => 'title', >+ 1003 => 'author' > } > } > }; >@@ -68,7 +72,7 @@ subtest 'test_search' => sub { > $search->mock('simple_search_compat', sub { > my ( $self, $query ) = @_; > >- return (1, undef, 0) unless $query eq '((author:(author)) AND ((title:(title\(s\))) OR (title:(another))))'; >+ return ('unexpected query', undef, 0) unless $query eq '((author:(author)) AND ((title:(title\(s\))) OR (title:(another))))'; > > my @records = ($marc_record_1, $marc_record_2); > return (undef, \@records, 2); >@@ -76,16 +80,16 @@ subtest 'test_search' => sub { > > $child = fork(); > if ($child == 0) { >- my @yaz_options = ( '@:42111' ); >+ my $config_dir = dirname(__FILE__) . '/'; > my $z = Koha::Z3950Responder->new( { >- config_dir => '', >- yaz_options => [ @yaz_options ] >+ config_dir => $config_dir > }); > $z->start(); > exit; > } > sleep(1); > >+ # Z39.50 protocol tests > my $o = new ZOOM::Options(); > $o->option(preferredRecordSyntax => 'xml'); > $o->option(elementSetName => 'marcxml'); >@@ -94,7 +98,7 @@ subtest 'test_search' => sub { > my $Zconn = ZOOM::Connection->create($o); > ok($Zconn, 'ZOOM connection created'); > >- $Zconn->connect('127.0.0.1:42111', 0); >+ $Zconn->connect('localhost:42111', 0); > is($Zconn->errcode(), 0, 'Connection is successful: ' . $Zconn->errmsg()); > > my $rs = $Zconn->search_pqf('@and @attr 1=1 @attr 4=1 author @or @attr 1=4 title(s) @attr 1=4 another'); >@@ -103,15 +107,46 @@ subtest 'test_search' => sub { > is($rs->size(), 2, 'Two results returned'); > > my $returned1 = MARC::Record->new_from_xml($rs->record(0)->raw()); >- ok ($returned1, 'Record 1 returned as MARCXML'); >+ ok($returned1, 'Record 1 returned as MARCXML'); > is($returned1->as_xml, $marc_record_1->as_xml, 'Record 1 returned properly'); > > my $returned2= MARC::Record->new_from_xml($rs->record(1)->raw()); >- ok ($returned2, 'Record 2 returned as MARCXML'); >+ ok($returned2, 'Record 2 returned as MARCXML'); > is($returned2->as_xml, $marc_record_2->as_xml, 'Record 2 returned properly'); > > is($rs->record(2), undef, 'Record 3 does not exist'); > >+ # SRU protocol tests >+ my $base = 'http://localhost:42111'; >+ my $ns = 'http://docs.oasis-open.org/ns/search-ws/sruResponse'; >+ my $marc_ns = 'http://www.loc.gov/MARC21/slim'; >+ my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); >+ >+ $agent->get_ok("$base", 'Retrieve explain response'); >+ my $dom = XML::LibXML->load_xml(string => $agent->content()); >+ my @nodes = $dom->getElementsByTagNameNS($ns, 'explainResponse'); >+ is(scalar(@nodes), 1, 'explainResponse returned'); >+ >+ $agent->get_ok("$base/biblios?operation=searchRetrieve&recordSchema=marcxml&maximumRecords=10&query=", 'Try bad search query'); >+ $dom = XML::LibXML->load_xml(string => $agent->content()); >+ @nodes = $dom->getElementsByTagNameNS($ns, 'diagnostics'); >+ is(scalar(@nodes), 1, 'diagnostics returned for bad query'); >+ >+ $agent->get_ok("$base/biblios?operation=searchRetrieve&recordSchema=marcxml&maximumRecords=10&query=(dc.author%3dauthor AND (dc.title%3d\"title(s)\" OR dc.title%3danother))", 'Retrieve search results'); >+ $dom = XML::LibXML->load_xml(string => $agent->content()); >+ @nodes = $dom->getElementsByTagNameNS($ns, 'searchRetrieveResponse'); >+ is(scalar(@nodes), 1, 'searchRetrieveResponse returned'); >+ my @records = $nodes[0]->getElementsByTagNameNS($marc_ns, 'record'); >+ is(scalar(@records), 2, 'Two results returned'); >+ >+ $returned1 = MARC::Record->new_from_xml($records[0]->toString()); >+ ok($returned1, 'Record 1 returned as MARCXML'); >+ is($returned1->as_xml, $marc_record_1->as_xml, 'Record 1 returned properly'); >+ >+ $returned2= MARC::Record->new_from_xml($records[1]->toString()); >+ ok($returned2, 'Record 2 returned as MARCXML'); >+ is($returned2->as_xml, $marc_record_2->as_xml, 'Record 2 returned properly'); >+ > cleanup(); > }; > >@@ -122,8 +157,7 @@ sub cleanup { > } > } > >-# Fall back to make sure that the Zebra process >-# and files get cleaned up >+# Fall back to make sure that the server process gets cleaned up > END { > cleanup(); > } >diff --git a/t/db_dependent/Koha/Z3950Responder/config.xml b/t/db_dependent/Koha/Z3950Responder/config.xml >new file mode 100644 >index 0000000000..68587d9653 >--- /dev/null >+++ b/t/db_dependent/Koha/Z3950Responder/config.xml >@@ -0,0 +1,13 @@ >+<yazgfs> >+ <listen id="public">tcp:localhost:42111</listen> >+ <server> >+ <cql2rpn>../../../../etc/z3950/pqf.properties</cql2rpn> >+ <explain xmlns="http://explain.z3950.org/dtd/2.0/"> >+ <retrievalinfo> >+ <retrieval syntax="usmarc" name="marc21"/> >+ <retrieval syntax="unimarc" name="unimarc"/> >+ <retrieval syntax="xml" name="marcxml" identifier="info:srw/schema/1/marcxml-v1.1"/> >+ </retrievalinfo> >+ </explain> >+ </server> >+</yazgfs> >-- >2.17.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 13937
:
46369
|
47417
|
47418
|
47419
|
53503
|
58122
|
58125
|
58126
|
59443
|
59444
|
60735
|
60736
|
60737
|
60738
|
66943
|
66944
|
66945
|
66946
|
69139
|
82562
|
82563
|
82564
|
82565
|
82566
|
82567
|
82589
|
82590
|
82591
|
82592
|
82593
|
82594
|
82595
|
82660
|
82661
|
82662
|
82663
|
82664
|
82665
|
82666
|
82667
|
83780
|
83781
|
83782
|
83783
|
83784
|
83785
|
83786
|
83787
|
83788
|
83789
|
83951
|
83952
|
83953
|
83954
|
83955
|
83956
|
83957
|
83958
|
83959
|
84050
|
84051
|
84052
|
84053
|
84054
|
84055
|
84056
|
84057
|
84058
|
84059
|
84062
|
84063
|
84064
|
84065
|
84066
|
84067
|
84068
|
84069
|
84072
|
84073
|
85112
|
86353
|
86354
|
86355
|
86356
|
86357
|
86358
|
86359
|
86360
|
86361
|
86362
|
86363
|
86364
|
88907
|
88908
|
88909
|
88910
|
88911
|
88912
|
88913
|
88914
|
88915
|
88916
|
88917
|
88918
|
91728
|
91729
|
91730
|
91731
|
91732
|
91733
|
91734
|
91735
|
91736
|
91737
|
91738
|
91739
| 91740 |
93913
|
94097
|
94109
|
94110
|
94209
|
94616
|
94647