5 use Test::More tests => 66;
8 use File::Temp qw/tempdir/;
13 my $debug = shift @ARGV;
16 use_ok( 'WebPAC::Lookup' );
17 use_ok( 'WebPAC::Input' );
18 use_ok( 'WebPAC::Store' );
19 use_ok( 'WebPAC::Normalize::XML' );
20 use_ok( 'WebPAC::Normalize::Set' );
21 use_ok( 'WebPAC::Output::TT' );
24 ok(my $abs_path = abs_path($0), "abs_path");
25 $abs_path =~ s#/[^/]*$#/#;
26 diag "abs_path: $abs_path" if ($debug);
28 my $isis_file = "$abs_path../t/winisis/BIBL";
29 #$isis_file = '/data/hidra/THS/THS';
30 $isis_file = '/data/isis_data/ffkk/';
32 diag "isis_file: $isis_file" if ($debug);
34 my $normalize_set_pl = "$abs_path/data/normalize.pl";
35 my $lookup_file = "$abs_path../conf/lookup/isis.pm";
37 ok(my $lookup = new WebPAC::Lookup(
38 lookup_file => $lookup_file,
41 ok(my $isis = new WebPAC::Input(
42 module => 'WebPAC::Input::ISIS',
43 code_page => 'ISO-8859-2', # application encoding
45 ), "new Input::ISIS");
47 ok(my $maxmfn = $isis->open(
49 code_page => '852', # database encoding
51 ), "Input::ISIS->open");
53 ok(my $path = tempdir( CLEANUP => 1 ), "path");
55 ok(my $db = new WebPAC::Store(
60 ok(my $n = new WebPAC::Normalize::XML(
61 # filter => { 'foo' => sub { shift } },
63 lookup_regex => $lookup->regex,
65 ), "new Normalize::XML");
69 xml_file => "$abs_path/data/normalize.xml",
70 ), "Normalize::XML->open");
72 ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
74 ok(my $out = new WebPAC::Output::TT(
75 include_path => "$abs_path../conf/output/tt",
76 filters => { foo => sub { shift } },
79 while (my $row = $isis->fetch) {
81 diag " row => ",Dumper($row) if ($debug);
84 ok(my $ds = $n->data_structure($row), "data_structure");
86 diag " ds => ",Dumper($ds) if ($debug);
91 use WebPAC::Normalize::Set;
92 diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug);
93 set_lookup( $lookup->lookup_hash );
96 ok(! $@, $@ ? "error: $@" : "no error");
97 ok(my $ds2 = get_ds(), "get_ds");
98 is_deeply( $ds, $ds2, 'ds same for xml and sets');
100 diag " ds2 => ",Dumper($ds2) if ($debug);
103 ok(my $html = $out->apply(
104 template => 'html.tt',
108 $html =~ s#\s*[\n\r]+\s*##gs;