/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 366 - (hide annotations)
Sun Jan 8 20:27:21 2006 UTC (18 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1736 byte(s)
 r395@llin:  dpavlin | 2006-01-08 21:27:12 +0100
 fix path to normalize file

1 dpavlin 22 #!/usr/bin/perl -w
2    
3     use strict;
4    
5 dpavlin 33 use Test::More tests => 34;
6 dpavlin 22 use Test::Exception;
7     use Cwd qw/abs_path/;
8     use File::Temp qw/tempdir/;
9 dpavlin 33 use Data::Dumper;
10 dpavlin 22 use blib;
11    
12     BEGIN {
13     use_ok( 'WebPAC::Lookup' );
14 dpavlin 300 use_ok( 'WebPAC::Input' );
15 dpavlin 209 use_ok( 'WebPAC::Store' );
16 dpavlin 22 use_ok( 'WebPAC::Normalize::XML' );
17     use_ok( 'WebPAC::Output::TT' );
18     }
19    
20     ok(my $abs_path = abs_path($0), "abs_path");
21     $abs_path =~ s#/[^/]*$#/#;
22     diag "abs_path: $abs_path";
23    
24     my $isis_file = "$abs_path../t/winisis/BIBL";
25 dpavlin 31 $isis_file = '/data/hidra/THS/THS';
26 dpavlin 22
27     diag "isis_file: $isis_file";
28    
29     ok(my $lookup = new WebPAC::Lookup(
30     lookup_file => "$abs_path../conf/lookup/isis.pm",
31     ), "new Lookup");
32    
33 dpavlin 300 ok(my $isis = new WebPAC::Input(
34     module => 'WebPAC::Input::ISIS',
35 dpavlin 22 code_page => 'ISO-8859-2', # application encoding
36 dpavlin 300 limit => 10,
37 dpavlin 22 ), "new Input::ISIS");
38    
39     ok(my $maxmfn = $isis->open(
40 dpavlin 300 path => $isis_file,
41 dpavlin 22 code_page => '852', # database encoding
42 dpavlin 252 lookup => $lookup,
43 dpavlin 22 ), "Input::ISIS->open");
44    
45     ok(my $path = tempdir( CLEANUP => 1 ), "path");
46    
47 dpavlin 209 ok(my $db = new WebPAC::Store(
48 dpavlin 22 path => $path,
49 dpavlin 217 database => '.',
50 dpavlin 209 ), "new Store");
51 dpavlin 22
52     ok(my $n = new WebPAC::Normalize::XML(
53     # filter => { 'foo' => sub { shift } },
54     db => $db,
55     lookup_regex => $lookup->regex,
56 dpavlin 31 lookup => $lookup,
57 dpavlin 22 ), "new Normalize::XML");
58    
59     ok($n->open(
60     tag => 'isis',
61 dpavlin 366 xml_file => "$abs_path/data/normalize.xml",
62 dpavlin 22 ), "Normalize::XML->open");
63    
64     ok(my $out = new WebPAC::Output::TT(
65     include_path => "$abs_path../conf/output/tt",
66     filters => { foo => sub { shift } },
67     ), "new Output::TT");
68    
69     while (my $row = $isis->fetch) {
70    
71 dpavlin 70 ok(my $ds = $n->data_structure($row), "data_structure");
72 dpavlin 22
73 dpavlin 70 # diag Dumper($ds);
74 dpavlin 22
75 dpavlin 33 ok(my $html = $out->apply(
76 dpavlin 22 template => 'html.tt',
77 dpavlin 70 data => $ds,
78 dpavlin 22 ), "apply");
79    
80 dpavlin 33 $html =~ s#\s*[\n\r]+\s*##gs;
81    
82 dpavlin 352 #diag $html;
83 dpavlin 33
84 dpavlin 22 };

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26