From 3b34b5158da2cceee85f28b872365c1050e5f9aa Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 7 Jun 2010 18:04:05 +0100 Subject: [PATCH] First functional Bath test. --- lib/ZOOM/IRSpy/Test/Search/Bath.pm | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 lib/ZOOM/IRSpy/Test/Search/Bath.pm diff --git a/lib/ZOOM/IRSpy/Test/Search/Bath.pm b/lib/ZOOM/IRSpy/Test/Search/Bath.pm new file mode 100644 index 0000000..ad2321a --- /dev/null +++ b/lib/ZOOM/IRSpy/Test/Search/Bath.pm @@ -0,0 +1,84 @@ +# This tests the main searches specified The Bath Profile, Release 2.0, +# http://www.collectionscanada.gc.ca/bath/tp-bath2-e.htm +# Specifically section 5.A.0 ("Functional Area A: Level 0 Basic +# Bibliographic Search and Retrieval") the its subsections. + +package ZOOM::IRSpy::Test::Search::Bath; + +use 5.008; +use strict; +use warnings; + +use ZOOM::IRSpy::Test; +our @ISA = qw(ZOOM::IRSpy::Test); + +use ZOOM::IRSpy::Utils qw(isodate); + + +my @bath_queries = ( + [ author => 1003 ], # 5.A.0.1 + [ title => 4 ], # 5.A.0.2 + [ subject => 21 ], # 5.A.0.3 + [ any => 1016 ], # 5.A.0.4 + ); + + +sub start { + my $class = shift(); + my($conn) = @_; + + start_search($conn, 0); +} + + +sub start_search { + my($conn, $qindex) = @_; + + return ZOOM::IRSpy::Status::TEST_GOOD + if $qindex >= @bath_queries; + + my $ref = $bath_queries[$qindex]; + my($name, $use_attr) = @$ref; + + my $query = "\@attr 1=$use_attr \@attr 2=3 \@attr 3=3 \@attr 4=2 \@attr 5=100 \@attr 6=1 the"; + $conn->irspy_search_pqf($query, { qindex => $qindex }, {}, + ZOOM::Event::ZEND, \&found, + "exception", \&error); + return ZOOM::IRSpy::Status::TASK_DONE; +} + + +sub found { + my($conn, $task, $udata, $event) = @_; + + my $qindex = $udata->{qindex}; + my $ref = $bath_queries[$qindex]; + my($name, $use_attr) = @$ref; + + my $n = $task->{rs}->size(); + + $conn->log("irspy_test", + "bath search #$qindex ('$name') found $n record", + $n==1 ? "" : "s"); + my $rec = $conn->record(); + $rec->append_entry("irspy:status", + "" . + isodate(time()) . ""); + + return start_search($conn, $qindex+1); +} + + +sub error { + my($conn, $task, $udata, $exception) = @_; + + $conn->log("irspy_test", "bath search had error: $exception"); + my $rec = $conn->record(); + $rec->append_entry("irspy:status", "" . + isodate(time()) . ""); + zoom_error_timeout_update($conn, $exception); + return ZOOM::IRSpy::Status::TASK_DONE; +} + + +1; -- 1.7.10.4