/[webpac2]/trunk/t/6-unit.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/6-unit.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 252 by dpavlin, Thu Dec 15 17:01:04 2005 UTC revision 482 by dpavlin, Sun May 14 09:33:56 2006 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 34;  use Test::More tests => 66;
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 File::Slurp;
10  use Data::Dumper;  use Data::Dumper;
11  use blib;  use blib;
12    
13    my $debug = shift @ARGV;
14    
15  BEGIN {  BEGIN {
16  use_ok( 'WebPAC::Lookup' );  use_ok( 'WebPAC::Lookup' );
17  use_ok( 'WebPAC::Input::ISIS' );  use_ok( 'WebPAC::Input' );
18  use_ok( 'WebPAC::Store' );  use_ok( 'WebPAC::Store' );
19  use_ok( 'WebPAC::Normalize::XML' );  use_ok( 'WebPAC::Normalize::XML' );
20    use_ok( 'WebPAC::Normalize::Set' );
21  use_ok( 'WebPAC::Output::TT' );  use_ok( 'WebPAC::Output::TT' );
22  }  }
23    
24  ok(my $abs_path = abs_path($0), "abs_path");  ok(my $abs_path = abs_path($0), "abs_path");
25  $abs_path =~ s#/[^/]*$#/#;  $abs_path =~ s#/[^/]*$#/#;
26  diag "abs_path: $abs_path";  diag "abs_path: $abs_path" if ($debug);
27    
28  my $isis_file = "$abs_path../t/winisis/BIBL";  my $isis_file = "$abs_path../t/winisis/BIBL";
29  $isis_file = '/data/hidra/THS/THS';  #$isis_file = '/data/hidra/THS/THS';
30    $isis_file = '/data/isis_data/ffkk/';
31    
32    diag "isis_file: $isis_file" if ($debug);
33    
34  diag "isis_file: $isis_file";  my $normalize_set_pl = "$abs_path/data/normalize.pl";
35    my $lookup_file = "$abs_path../conf/lookup/isis.pm";
36    
37  ok(my $lookup = new WebPAC::Lookup(  ok(my $lookup = new WebPAC::Lookup(
38          lookup_file => "$abs_path../conf/lookup/isis.pm",          lookup_file => $lookup_file,
39  ), "new Lookup");  ), "new Lookup");
40    
41  ok(my $isis = new WebPAC::Input::ISIS(  ok(my $isis = new WebPAC::Input(
42            module => 'WebPAC::Input::ISIS',
43          code_page => 'ISO-8859-2',      # application encoding          code_page => 'ISO-8859-2',      # application encoding
44          limit_mfn => 10,  #       limit => 10,
45  ), "new Input::ISIS");  ), "new Input::ISIS");
46    
47  ok(my $maxmfn = $isis->open(  ok(my $maxmfn = $isis->open(
48          filename => $isis_file,          path => $isis_file,
49          code_page => '852',             # database encoding          code_page => '852',             # database encoding
50          lookup => $lookup,          lookup => $lookup,
51  ), "Input::ISIS->open");  ), "Input::ISIS->open");
# Line 57  ok(my $n = new WebPAC::Normalize::XML( Line 66  ok(my $n = new WebPAC::Normalize::XML(
66    
67  ok($n->open(  ok($n->open(
68          tag => 'isis',          tag => 'isis',
69          xml_file => "$abs_path../conf/normalize/isis.xml",          xml_file => "$abs_path/data/normalize.xml",
70  ), "Normalize::XML->open");  ), "Normalize::XML->open");
71    
72    ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
73    
74  ok(my $out = new WebPAC::Output::TT(  ok(my $out = new WebPAC::Output::TT(
75          include_path => "$abs_path../conf/output/tt",          include_path => "$abs_path../conf/output/tt",
76          filters => { foo => sub { shift } },          filters => { foo => sub { shift } },
77  ), "new Output::TT");  ), "new Output::TT");
78    
79  while (my $row = $isis->fetch) {  diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug);
80            
81    foreach my $pos ( 0 ... $isis->size ) {
82    
83            my $row = $isis->fetch || next;
84    
85            diag " row $pos => ",Dumper($row) if ($debug);
86            set_rec( $row );
87    
88          ok(my $ds = $n->data_structure($row), "data_structure");          ok(my $ds = $n->data_structure($row), "data_structure");
89    
90  #       diag Dumper($ds);          diag " ds $pos => ",Dumper($ds) if ($debug);
91    
92            # TODO move somewhere
93            {
94                    no strict 'subs';
95                    use WebPAC::Normalize::Set;
96                    set_lookup( $lookup->lookup_hash );
97                    clean_ds();
98                    eval "$norm_pl";
99                    ok(! $@, $@ ? "error: $@" : "no error");
100                    ok(my $ds2 = get_ds(), "get_ds");
101                    is_deeply( $ds, $ds2, 'ds same for xml and sets');
102    
103                    diag " ds2 $pos => ",Dumper($ds2) if ($debug);
104            }
105    
106          ok(my $html = $out->apply(          ok(my $html = $out->apply(
107                  template => 'html.tt',                  template => 'html.tt',
# Line 78  while (my $row = $isis->fetch) { Line 110  while (my $row = $isis->fetch) {
110    
111          $html =~ s#\s*[\n\r]+\s*##gs;          $html =~ s#\s*[\n\r]+\s*##gs;
112    
113          diag $html;          #diag $html;
114    
115  };  };

Legend:
Removed from v.252  
changed lines
  Added in v.482

  ViewVC Help
Powered by ViewVC 1.1.26