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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 252 - (show annotations)
Thu Dec 15 17:01:04 2005 UTC (18 years, 4 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1728 byte(s)
 r11711@llin:  dpavlin | 2005-12-15 20:02:16 +0100
 varios tweaks to make lookups work

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26