Getting ready to test available record formats.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Record / Fetch.pm
1 # $Id: Fetch.pm,v 1.1 2006-10-23 13:54:52 sondberg Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Record::Fetch;
6
7 use 5.008;
8 use strict;
9 use warnings;
10
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
13
14
15 sub start {
16     print STDERR "Got here\n";
17     exit 1;
18     my $class = shift();
19     my($conn) = @_;
20     my @syntax = ( 'canmarc',
21                    'danmarc',
22                    'grs-1',
23                    'ibermarc',
24                    'intermarc',
25                    'jpmarc',
26                    'librismarc',
27                    'mab',
28                    'normarc',
29                    'opac',
30                    'picamarc',
31                    'rusmarc',
32                    'summary',
33                    'sutrs',
34                    'swemarc'
35                    'ukmarc',
36                    'unimarc',
37                    'usmarc',
38                    'xml',
39                 );
40
41     foreach my $syn (@syntax) {
42         $conn->option('preferredRecordSyntax' => $syn);
43         $conn->option('start'   => 0);
44         $conn->option('count'   => 1);
45
46         ## Here I want to get a use attribute from the session, which we've
47         ## managed to search for in the Search/Bib1 or Search/Dan1 tests. But
48         ## how? So far we search for title: 1=4
49         $conn->irspy_search_pqf("\@attr 1=4 mineral",
50                                 {'syntax' => $syn},
51                                 ZOOM::Event::RECV_RECORD, \&record,
52                                 exception => \&error);
53     }
54 }
55
56
57 sub record {
58     my($conn, $task, $test_args, $event) = @_;
59     my $syn = $test_args->{'syn'};
60
61     $conn->log("irspy_test", "search on access-point $attr found $n record",
62                $n==1 ? "" : "s");
63     $conn->record()->store_result('record_fetch',
64                                   'syntax'   => $syn,
65                                   'ok'       => 1);
66
67     return ZOOM::IRSpy::Status::TASK_DONE;
68 }
69
70
71 sub error {
72     my($conn, $task, $test_args, $exception) = @_;
73     my $syn = $test_args->{'syn'};
74
75     $conn->log("irspy_test", "search on access-point $attr had error: ",
76                $exception);
77     $conn->record()->store_result('record_fetch',
78                                   'syntax'       => $syn,
79                                   'ok'        => 0);
80     return ZOOM::IRSpy::Status::TASK_DONE;
81 }
82
83
84 1;