/[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 22 by dpavlin, Sun Jul 17 22:48:25 2005 UTC revision 352 by dpavlin, Sat Jan 7 18:23:27 2006 UTC
# Line 2  Line 2 
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' );
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  }  }
# Line 21  $abs_path =~ s#/[^/]*$#/#; Line 22  $abs_path =~ s#/[^/]*$#/#;
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    
# Line 28  ok(my $lookup = new WebPAC::Lookup( Line 30  ok(my $lookup = new WebPAC::Lookup(
30          lookup_file => "$abs_path../conf/lookup/isis.pm",          lookup_file => "$abs_path../conf/lookup/isis.pm",
31  ), "new Lookup");  ), "new Lookup");
32    
33  ok(my $isis = new WebPAC::Input::ISIS(  ok(my $isis = new WebPAC::Input(
34            module => 'WebPAC::Input::ISIS',
35          code_page => 'ISO-8859-2',      # application encoding          code_page => 'ISO-8859-2',      # application encoding
36            limit => 10,
37  ), "new Input::ISIS");  ), "new Input::ISIS");
38    
39  ok(my $maxmfn = $isis->open(  ok(my $maxmfn = $isis->open(
40          filename => $isis_file,          path => $isis_file,
41          code_page => '852',             # database encoding          code_page => '852',             # database encoding
42            lookup => $lookup,
43  ), "Input::ISIS->open");  ), "Input::ISIS->open");
44    
45  ok(my $path = tempdir( CLEANUP => 1 ), "path");  ok(my $path = tempdir( CLEANUP => 1 ), "path");
46    
47  ok(my $db = new WebPAC::DB(  ok(my $db = new WebPAC::Store(
48          path => $path,          path => $path,
49  ), "new DB");          database => '.',
50    ), "new Store");
51    
52  ok(my $n = new WebPAC::Normalize::XML(  ok(my $n = new WebPAC::Normalize::XML(
53  #       filter => { 'foo' => sub { shift } },  #       filter => { 'foo' => sub { shift } },
54          db => $db,          db => $db,
55          lookup_regex => $lookup->regex,          lookup_regex => $lookup->regex,
56          debug => 1,          lookup => $lookup,
57  ), "new Normalize::XML");  ), "new Normalize::XML");
58    
59  ok($n->open(  ok($n->open(
# Line 62  ok(my $out = new WebPAC::Output::TT( Line 68  ok(my $out = new WebPAC::Output::TT(
68    
69  while (my $row = $isis->fetch) {  while (my $row = $isis->fetch) {
70                    
71          ok(my @ds = $n->data_structure($row), "data_structure");          ok(my $ds = $n->data_structure($row), "data_structure");
72    
73  use Data::Dumper;  #       diag Dumper($ds);
 print Dumper(\@ds);  
74    
75          ok($out->apply(          ok(my $html = $out->apply(
76                  template => 'html.tt',                  template => 'html.tt',
77                  data => @ds,                  data => $ds,
78          ), "apply");          ), "apply");
79    
80            $html =~ s#\s*[\n\r]+\s*##gs;
81    
82            #diag $html;
83    
84  };  };

Legend:
Removed from v.22  
changed lines
  Added in v.352

  ViewVC Help
Powered by ViewVC 1.1.26