1 # $Id: Fetch.pm,v 1.18 2006-12-18 15:36:03 mike Exp $
3 # See the "Main" test package for documentation
5 package ZOOM::IRSpy::Test::Record::Fetch;
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
18 "\@attr 1=4 computer",
19 ### We can add more queries here
27 # Here I want to get a use attribute from the session, which we've
28 # managed to search for in the Search/Bib1 or Search/Dan1 tests.
29 # But how? So far we search for title: 1=4
30 $conn->irspy_search_pqf($queries[0], { queryindex => 0 }, {},
31 ZOOM::Event::RECV_SEARCH, \&completed_search,
32 exception => \&search_error);
36 sub completed_search {
37 my($conn, $task, $udata, $event) = @_;
39 my $n = $task->{rs}->size();
40 $conn->log("irspy_test", "Fetch test search found $n records");
42 my $n = $udata->{queryindex}+1;
45 $conn->log("irspy_test", "Trying another search ...");
46 $conn->irspy_search_pqf($queries[$n], { queryindex => $n }, {},
47 ZOOM::Event::RECV_SEARCH, \&completed_search,
48 exception => \&search_error);
49 return ZOOM::IRSpy::Status::TASK_DONE;
51 return ZOOM::IRSpy::Status::TEST_SKIPPED;
76 #@syntax = qw(grs-1 sutrs usmarc xml); # simplify for debugging
77 foreach my $i (0 ..$#syntax) {
78 my $syntax = $syntax[$i];
79 $conn->irspy_rs_record($task->{rs}, 0,
81 last => ($i == $#syntax) },
82 { start => 0, count => 1,
83 preferredRecordSyntax => $syntax },
84 ZOOM::Event::RECV_RECORD, \&record,
85 exception => \&fetch_error);
88 return ZOOM::IRSpy::Status::TASK_DONE;
93 my($conn, $task, $udata, $event) = @_;
94 my $syn = $udata->{'syntax'};
97 my $record = _fetch_record($rs, 0, $syn);
99 if ($record->error()) {
100 $conn->log("irspy_test", "retrieval of $syn record failed: ",
101 $record->exception());
104 my $text = $record->render();
105 $conn->log("irspy_test", "Successfully retrieved a $syn record");
107 print STDERR "Hits: ", $rs->size(), "\n";
108 print STDERR "Syntax: ", $syn, "\n";
113 $conn->record()->store_result('record_fetch',
117 return ($udata->{last} ?
118 ZOOM::IRSpy::Status::TEST_GOOD :
119 ZOOM::IRSpy::Status::TASK_DONE);
124 my($rs, $index0, $syntax) = @_;
126 my $oldSyntax = $rs->option(preferredRecordSyntax => $syntax);
127 my $record = $rs->record(0);
128 $oldSyntax = "" if !defined $oldSyntax;
129 $rs->option(preferredRecordSyntax => $oldSyntax);
136 my($conn, $task, $test_args, $exception) = @_;
138 $conn->log("irspy_test", "Initial search failed: ", $exception);
139 return ZOOM::IRSpy::Status::TEST_SKIPPED;
144 my($conn, $task, $test_args, $exception) = @_;
145 my $syn = $test_args->{'syntax'};
147 $conn->log("irspy_test", "Retrieval of $syn record failed: ", $exception);
148 $conn->record()->store_result('record_fetch',
151 return ZOOM::IRSpy::Status::TASK_DONE;