r1393@llin: dpavlin | 2007-10-31 00:52:52 +0100
[webpac2] / t / 2-parse.t
index 45579e7..36f4da2 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 43;
+use Test::More tests => 55;
 use Test::Exception;
 use blib;
 
@@ -54,7 +54,7 @@ ok($parser->{_lookup_create}, "_lookup_create");
 diag "_lookup_create_key = ",dump($l) if ($debug);
 foreach my $db (keys %$l) {
        foreach my $i (keys %{$l->{$db}}) {
-               ok(defined($parser->lookup_create_rules($db,$i)), "have $db/$i");
+               ok(defined($parser->lookup_create_rules($db,$i)), "lookup_create_rules($db/$i)");
                my @keys = sort keys %{$l->{$db}->{$i}};
                ok(@keys, 'have keys');
                my @have_keys = sort $parser->have_lookup_create($db,$i);
@@ -65,6 +65,13 @@ foreach my $db (keys %$l) {
 
 ok(my $n = $parser->{_normalize_source}, "_normalize_source");
 diag "_normalize_source = ",dump($n) if ($debug);
+foreach my $db (keys %$n) {
+       foreach my $i (keys %{$n->{$db}}) {
+               ok(my $r = $parser->normalize_rules($db,$i), "normalize_source($db/$i)");
+               diag "normalize_rules($db,$i) = $r" if ($debug);
+               cmp_ok($n->{$db}->{$i}, 'eq', $r, "same");
+       }
+}
 
 ok(my $d = $parser->{depends}, "depends");
 diag "depends = ",dump($d) if ($debug);
@@ -105,3 +112,29 @@ foreach my $db (keys %$d) {
        }
 }
 
+$config_path = "$abs_path/conf/marc.yml";
+
+ok(-e $config_path, "$config_path exists");
+
+ok(
+       my $parser = new WebPAC::Parser(
+               config => new WebPAC::Config( path => $config_path ),
+               base_path => $abs_path,
+               debug => $debug,
+), "new");
+
+ok(my $marc = $parser->have_rules('marc', 'marc', 'marc-input'), 'have_rules(marc,...)');
+
+diag "marc: ",dump($marc) if ($debug);
+
+is_deeply($marc, {
+       marc                                            => 1,
+       marc_compose                            => 1,
+       marc_duplicate                          => 1,
+       marc_indicators                         => 1,
+       marc_leader                                     => 1,
+       marc_original_order                     => 1,
+       marc_remove                                     => 1,
+       marc_repeatable_subfield        => 1,
+}, 'catched all marc_*');
+