1 # $Id: Fetch.pm,v 1.21 2007-02-13 14:35:04 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 => \&completed_search);
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 $qindex = $udata->{queryindex}+1;
44 my $q = $queries[$qindex];
45 return ZOOM::IRSpy::Status::TEST_SKIPPED
48 $conn->log("irspy_test", "Trying another search ...");
49 $conn->irspy_search_pqf($queries[$qindex], { queryindex => $n }, {},
50 ZOOM::Event::RECV_SEARCH, \&completed_search,
51 exception => \&completed_search);
52 return ZOOM::IRSpy::Status::TASK_DONE;
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);
135 sub __UNUSED_search_error {
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;