/[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 29 - (show annotations)
Sun Jul 24 11:17:44 2005 UTC (18 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1550 byte(s)
some logging improvements and sample configuration file

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26