File: 06-sru.t

package info (click to toggle)
libcatmandu-mab2-perl 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 376 kB
  • sloc: perl: 816; xml: 23; makefile: 16; sh: 4
file content (41 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use strict;
use warnings;
use Test::More;
use Test::Exception;
use Catmandu::Importer::SRU;
use Catmandu::Importer::SRU::Parser::mabxml;

use FindBin;
use lib "$FindBin::Bin/lib";
use MockFurl;


my %attrs = (
    base => 'http://www.unicat.be/sru',
    query => 'sru_mabxml.xml',
    recordSchema => 'mabxml',
    furl => MockFurl->new,
);

my $importer = Catmandu::Importer::SRU->new(%attrs);
isa_ok($importer, 'Catmandu::Importer::SRU');
can_ok($importer, 'each');
is($importer->url, 'http://www.unicat.be/sru?version=1.1&operation=searchRetrieve&query=sru_mabxml.xml&recordSchema=mabxml&startRecord=1&maximumRecords=10');

my $mabparser = Catmandu::Importer::SRU::Parser::mabxml->new;

my @parsers = ( 
    'mabxml',
    '+Catmandu::Importer::SRU::Parser::mabxml',
    $mabparser,
    sub { $mabparser->parse($_[0]); }
);

foreach my $parser (@parsers) {
    my $importer = Catmandu::Importer::SRU->new(%attrs, parser => $parser);
    ok (my $obj = $importer->first, 'parse mabxml');
    ok (exists $obj->{_id} , 'mabxml has _id');
    ok (exists $obj->{record} , 'mabxml as record');
}

done_testing;