2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 23; |
use Test::More tests => 34; |
6 |
use Test::Exception; |
use Test::Exception; |
7 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
8 |
use File::Temp qw/tempdir/; |
use File::Temp qw/tempdir/; |
9 |
|
use Data::Dumper; |
10 |
use blib; |
use blib; |
11 |
|
|
12 |
BEGIN { |
BEGIN { |
13 |
use_ok( 'WebPAC::Lookup' ); |
use_ok( 'WebPAC::Lookup' ); |
14 |
use_ok( 'WebPAC::Input::ISIS' ); |
use_ok( 'WebPAC::Input::ISIS' ); |
15 |
use_ok( 'WebPAC::DB' ); |
use_ok( 'WebPAC::Store' ); |
16 |
use_ok( 'WebPAC::Normalize::XML' ); |
use_ok( 'WebPAC::Normalize::XML' ); |
17 |
use_ok( 'WebPAC::Output::TT' ); |
use_ok( 'WebPAC::Output::TT' ); |
18 |
} |
} |
22 |
diag "abs_path: $abs_path"; |
diag "abs_path: $abs_path"; |
23 |
|
|
24 |
my $isis_file = "$abs_path../t/winisis/BIBL"; |
my $isis_file = "$abs_path../t/winisis/BIBL"; |
25 |
|
$isis_file = '/data/hidra/THS/THS'; |
26 |
|
|
27 |
diag "isis_file: $isis_file"; |
diag "isis_file: $isis_file"; |
28 |
|
|
32 |
|
|
33 |
ok(my $isis = new WebPAC::Input::ISIS( |
ok(my $isis = new WebPAC::Input::ISIS( |
34 |
code_page => 'ISO-8859-2', # application encoding |
code_page => 'ISO-8859-2', # application encoding |
35 |
|
limit_mfn => 10, |
36 |
), "new Input::ISIS"); |
), "new Input::ISIS"); |
37 |
|
|
38 |
ok(my $maxmfn = $isis->open( |
ok(my $maxmfn = $isis->open( |
39 |
filename => $isis_file, |
filename => $isis_file, |
40 |
code_page => '852', # database encoding |
code_page => '852', # database encoding |
41 |
|
lookup => $lookup, |
42 |
), "Input::ISIS->open"); |
), "Input::ISIS->open"); |
43 |
|
|
44 |
ok(my $path = tempdir( CLEANUP => 1 ), "path"); |
ok(my $path = tempdir( CLEANUP => 1 ), "path"); |
45 |
|
|
46 |
ok(my $db = new WebPAC::DB( |
ok(my $db = new WebPAC::Store( |
47 |
path => $path, |
path => $path, |
48 |
), "new DB"); |
database => '.', |
49 |
|
), "new Store"); |
50 |
|
|
51 |
ok(my $n = new WebPAC::Normalize::XML( |
ok(my $n = new WebPAC::Normalize::XML( |
52 |
# filter => { 'foo' => sub { shift } }, |
# filter => { 'foo' => sub { shift } }, |
53 |
db => $db, |
db => $db, |
54 |
lookup_regex => $lookup->regex, |
lookup_regex => $lookup->regex, |
55 |
|
lookup => $lookup, |
56 |
), "new Normalize::XML"); |
), "new Normalize::XML"); |
57 |
|
|
58 |
ok($n->open( |
ok($n->open( |
67 |
|
|
68 |
while (my $row = $isis->fetch) { |
while (my $row = $isis->fetch) { |
69 |
|
|
70 |
ok(my @ds = $n->data_structure($row), "data_structure"); |
ok(my $ds = $n->data_structure($row), "data_structure"); |
71 |
|
|
72 |
use Data::Dumper; |
# diag Dumper($ds); |
|
print Dumper(\@ds); |
|
73 |
|
|
74 |
ok($out->apply( |
ok(my $html = $out->apply( |
75 |
template => 'html.tt', |
template => 'html.tt', |
76 |
data => @ds, |
data => $ds, |
77 |
), "apply"); |
), "apply"); |
78 |
|
|
79 |
|
$html =~ s#\s*[\n\r]+\s*##gs; |
80 |
|
|
81 |
|
diag $html; |
82 |
|
|
83 |
}; |
}; |