1 # $Id: Fetch.pm,v 1.19 2007-01-29 17:24:51 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 "\@attr 1=44 mineral", # Smithsonian doesn't support AP 4!
20 ### We can add more queries here
28 # Here I want to get a use attribute from the session, which we've
29 # managed to search for in the Search/Bib1 or Search/Dan1 tests.
30 # But how? So far we search for title: 1=4
31 $conn->irspy_search_pqf($queries[0], { queryindex => 0 }, {},
32 ZOOM::Event::RECV_SEARCH, \&completed_search,
33 exception => \&search_error);
37 sub completed_search {
38 my($conn, $task, $udata, $event) = @_;
40 my $n = $task->{rs}->size();
41 $conn->log("irspy_test", "Fetch test search found $n records");
43 my $n = $udata->{queryindex}+1;
46 $conn->log("irspy_test", "Trying another search ...");
47 $conn->irspy_search_pqf($queries[$n], { queryindex => $n }, {},
48 ZOOM::Event::RECV_SEARCH, \&completed_search,
49 exception => \&search_error);
50 return ZOOM::IRSpy::Status::TASK_DONE;
52 return ZOOM::IRSpy::Status::TEST_SKIPPED;
77 #@syntax = qw(grs-1 sutrs usmarc xml); # simplify for debugging
78 foreach my $i (0 ..$#syntax) {
79 my $syntax = $syntax[$i];
80 $conn->irspy_rs_record($task->{rs}, 0,
82 last => ($i == $#syntax) },
83 { start => 0, count => 1,
84 preferredRecordSyntax => $syntax },
85 ZOOM::Event::RECV_RECORD, \&record,
86 exception => \&fetch_error);
89 return ZOOM::IRSpy::Status::TASK_DONE;
94 my($conn, $task, $udata, $event) = @_;
95 my $syn = $udata->{'syntax'};
98 my $record = _fetch_record($rs, 0, $syn);
100 if ($record->error()) {
101 $conn->log("irspy_test", "retrieval of $syn record failed: ",
102 $record->exception());
105 my $text = $record->render();
106 $conn->log("irspy_test", "Successfully retrieved a $syn record");
108 print STDERR "Hits: ", $rs->size(), "\n";
109 print STDERR "Syntax: ", $syn, "\n";
114 $conn->record()->store_result('record_fetch',
118 return ($udata->{last} ?
119 ZOOM::IRSpy::Status::TEST_GOOD :
120 ZOOM::IRSpy::Status::TASK_DONE);
125 my($rs, $index0, $syntax) = @_;
127 my $oldSyntax = $rs->option(preferredRecordSyntax => $syntax);
128 my $record = $rs->record(0);
129 $oldSyntax = "" if !defined $oldSyntax;
130 $rs->option(preferredRecordSyntax => $oldSyntax);
137 my($conn, $task, $test_args, $exception) = @_;
139 $conn->log("irspy_test", "Initial search failed: ", $exception);
140 return ZOOM::IRSpy::Status::TEST_SKIPPED;
145 my($conn, $task, $test_args, $exception) = @_;
146 my $syn = $test_args->{'syntax'};
148 $conn->log("irspy_test", "Retrieval of $syn record failed: ", $exception);
149 $conn->record()->store_result('record_fetch',
152 return ZOOM::IRSpy::Status::TASK_DONE;