5 use Test::More tests => 31;
8 use File::Temp qw/tempdir/;
10 use Data::Dump qw/dump/;
11 use Time::HiRes qw/time/;
14 my $debug = shift @ARGV;
17 # FIXME add lookup testing!
21 use_ok( 'WebPAC::Input' );
22 use_ok( 'WebPAC::Store' );
23 use_ok( 'WebPAC::Normalize' );
24 use_ok( 'WebPAC::Output::TT' );
27 ok(my $abs_path = abs_path($0), "abs_path");
28 $abs_path =~ s#/[^/]*$#/#;
29 diag "abs_path: $abs_path" if ($debug);
31 my $isis_file = "$abs_path../t/winisis/BIBL";
32 #$isis_file = '/data/hidra/THS/THS';
33 #$isis_file = '/data/isis_data/ffkk/';
35 diag "isis_file: $isis_file" if ($debug);
37 my $normalize_set_pl = "$abs_path/data/normalize.pl";
38 my $lookup_file = "$abs_path../conf/lookup/isis.pm";
40 ok(my $isis = new WebPAC::Input(
41 module => 'WebPAC::Input::ISIS',
42 code_page => 'ISO-8859-2', # application encoding
45 ), "new Input::ISIS");
47 ok(my $maxmfn = $isis->open(
49 code_page => 'cp852', # database encoding
50 lookup_coderef => sub {
51 my $rec = shift || return;
52 ok($rec, 'lookup_coderef has rec');
53 ok(defined($rec->{'000'}->[0]), 'have mfn');
55 ), "Input::ISIS->open");
57 ok(my $path = tempdir( CLEANUP => 1 ), "path");
59 ok(my $db = new WebPAC::Store({
63 ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
65 ok(my $out = new WebPAC::Output::TT(
66 include_path => "$abs_path../conf/output/tt",
67 filters => { foo => sub { shift } },
72 foreach my $pos ( 0 ... $isis->size ) {
74 my $row = $isis->fetch || next;
76 diag " row $pos => ",dump($row) if ($debug);
79 ok( my $ds = WebPAC::Normalize::data_structure(
82 ), "Set data_structure");
83 $t_norm += time() - $t;
85 diag " ds $pos => ",dump($ds) if ($debug);
87 ok(my $html = $out->apply(
88 template => 'html.tt',
92 $html =~ s#\s*[\n\r]+\s*##gs;
98 diag sprintf("timings: %.2fs\n", $t_norm);