1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
|
use Test::More tests => 51; |
|
|
use Test::Exception; |
|
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Data::Dump qw/dump/; |
use Test::More tests => 55; |
7 |
use Cwd qw/abs_path/; |
|
8 |
use YAML qw/LoadFile/; |
use YAML qw/LoadFile/; |
9 |
|
|
10 |
BEGIN { |
BEGIN { |
11 |
|
use_ok( 'WebPAC::Test' ); |
12 |
use_ok( 'WebPAC::Parser' ); |
use_ok( 'WebPAC::Parser' ); |
13 |
use_ok( 'WebPAC::Config' ); |
use_ok( 'WebPAC::Config' ); |
14 |
} |
} |
15 |
|
|
|
my $debug = shift @ARGV; |
|
|
|
|
|
ok(my $abs_path = abs_path($0), "abs_path"); |
|
|
$abs_path =~ s#/[^/]*$#/#; |
|
|
|
|
16 |
my $config_path = "$abs_path/conf/test.yml"; |
my $config_path = "$abs_path/conf/test.yml"; |
17 |
|
|
18 |
ok(-e $config_path, "$config_path exists"); |
ok(-e $config_path, "$config_path exists"); |
19 |
|
|
20 |
throws_ok { new WebPAC::Parser( no_log => 1 ) } qr/WebPAC::Config/, "new without config"; |
throws_ok { new WebPAC::Parser( %LOG ) } qr/WebPAC::Config/, "new without config"; |
21 |
|
|
22 |
ok( |
ok( |
23 |
my $parser = new WebPAC::Parser( |
my $parser = new WebPAC::Parser( |
24 |
config => new WebPAC::Config( path => $config_path ), |
config => new WebPAC::Config( path => $config_path ), |
25 |
base_path => $abs_path, |
base_path => $abs_path, |
26 |
debug => $debug, |
%LOG |
27 |
), "new"); |
), "new"); |
28 |
|
|
29 |
my $inputs = { |
my $inputs = { |
106 |
} |
} |
107 |
} |
} |
108 |
|
|
109 |
|
$config_path = "$abs_path/conf/marc.yml"; |
110 |
|
|
111 |
|
ok(-e $config_path, "$config_path exists"); |
112 |
|
|
113 |
|
ok( |
114 |
|
my $parser = new WebPAC::Parser( |
115 |
|
config => new WebPAC::Config( path => $config_path ), |
116 |
|
base_path => $abs_path, |
117 |
|
%LOG, |
118 |
|
), "new"); |
119 |
|
|
120 |
|
ok(my $marc = $parser->have_rules('marc', 'marc', 'marc-input'), 'have_rules(marc,...)'); |
121 |
|
|
122 |
|
diag "marc: ",dump($marc) if ($debug); |
123 |
|
|
124 |
|
is_deeply($marc, { |
125 |
|
marc => 1, |
126 |
|
marc_compose => 1, |
127 |
|
marc_duplicate => 1, |
128 |
|
marc_indicators => 1, |
129 |
|
marc_leader => 1, |
130 |
|
marc_original_order => 1, |
131 |
|
marc_remove => 1, |
132 |
|
marc_repeatable_subfield => 1, |
133 |
|
}, 'catched all marc_*'); |
134 |
|
|