Tie in new MFHD method to serials module/MFHD tests for compressing, combining
authorDan Wells <dbw2@calvin.edu>
Tue, 7 May 2013 22:23:27 +0000 (18:23 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 9 Aug 2013 15:19:49 +0000 (11:19 -0400)
[This commit has been squashed for merging. LFW]

 *  Now that we have a potentially better alternative, let's call
    get_combined_holdings() in place of get_compressed_holdings() in
    Serial.pm.

 *  First, add a test for the new get_combined_holdings() method.

    Second, add a known problem case for get_compressed_holdings().
    The fix will come in a subsequent commit.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhd.t
Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhddata2.txt

index d79c5c6..c619d37 100644 (file)
@@ -1899,10 +1899,10 @@ sub _summarize_contents {
     foreach my $scap_field (@scap_fields_ordered) { #TODO: use generic MFHD "summarize" method, once available
         my @updated_holdings;
         eval {
-            @updated_holdings = $mfhd->get_compressed_holdings($scap_field);
+            @updated_holdings = $mfhd->get_combined_holdings($scap_field);
         };
         if ($@) {
-            my $msg = "get_compressed_holdings(): $@ ; using sdist ID #" .
+            my $msg = "get_combined_holdings(): $@ ; using sdist ID #" .
                 ($sdist ? $sdist->id : "<NONE>") . " and " .
                 scalar(@$issuances) . " issuances, of which one has ID #" .
                 $issuances->[0]->id;
index 29ee865..97e64fd 100644 (file)
@@ -89,6 +89,18 @@ $rec2 = MFHD->new(testlib::load_MARC_rec($testdata, $testno));
 is_deeply($holdings_a[0]->compressed_to_last, $holdings_b[0], 'compressed to last, normal');
 is($holdings_a[1]->compressed_to_last, undef, 'compressed to last, open ended');
 
+# test: get compressed holdings
+$testno++;
+
+$rec = MFHD->new(testlib::load_MARC_rec($testdata, $testno));
+$rec2 = MFHD->new(testlib::load_MARC_rec($testdata, $testno));
+
+@holdings_a = $rec->get_compressed_holdings(($rec->captions('853'))[0]);
+@holdings_b = $rec2->holdings_by_caption(($rec2->captions('853'))[0]);
+
+is_deeply(\@holdings_a, \@holdings_b, 'get compressed holdings');
+
+
 # test: get compressed holdings, open ended member
 $testno++;
 
@@ -126,5 +138,17 @@ foreach my $holding (@holdings_a) {
 
 is_deeply(\@holdings_a, \@holdings_b, 'comparison testing via sort');
 
+# test: get combined holdings
+$testno++;
+
+$rec = MFHD->new(testlib::load_MARC_rec($testdata, $testno));
+$rec2 = MFHD->new(testlib::load_MARC_rec($testdata, $testno));
+
+@holdings_a = $rec->get_combined_holdings(($rec->captions('853'))[0]);
+@holdings_b = $rec2->holdings_by_caption(($rec2->captions('853'))[0]);
+
+is_deeply(\@holdings_a, \@holdings_b, 'get combined holdings');
+
+
 close $testdata;
 1;
index a450bb4..65a6fe8 100644 (file)
 853 20 $81$av.$bno.$u12$vr$i(year)$j(month)$wm$x01
 863 41 $81.1$a1$b8$i1990$j08
 
+245 00 $aGet compressed holdings
+853 20 $81$av.$bno.$u12$vr$i(year)$j(month)$wm$x01
+863 40 $81.1$a1$b1-4$i1990$j01-04
+863 40 $81.2$a1$b2-3$i1990$j02-03
+863 40 $81.3$a1$b6-7$i1990$j06-07
+863 41 $81.4$a1$b8$i1990$j08
+863 41 $81.5$a1$b10$i1990$j10
+863 40 $81.6$a1-$b10-$i1990-$j10-
+863 41 $81.7$a1$b12$i1990$j12
+
+245 00 $aGet compressed holdings, result
+853 20 $81$av.$bno.$u12$vr$i(year)$j(month)$wm$x01
+863 40 $81.1$a1$b1-4$i1990$j01-04
+863 40 $81.2$a1$b6-8$i1990$j06-08
+863 40 $81.3$a1-$b10-$i1990-$j10-
+
 245 00 $aGet compressed holdings, open ended member
 853 20 $81$av.$bno.$u12$vr$i(year)$j(month)$wm$x01
 863 41 $81.1$a1$b4$i1990$j04
 863 40 $81.8$a1$b4-7$i1990$j04-07
 863 40 $81.9$a1$b4-7$i1990$j04-07
 
+245 00 $aGet combined holdings
+853 20 $81$av.$bno.$u12$vr$i(year)$j(month)$wm$x01
+863 40 $81.1$a1$b1-4$i1990$j01-04
+863 40 $81.2$a1$b2-3$i1990$j02-03
+863 40 $81.3$a1$b6-7$i1990$j06-07
+863 41 $81.4$a1$b8$i1990$j08
+863 41 $81.5$a1$b10$i1990$j10
+863 40 $81.6$a1-$b10-$i1990-$j10-
+863 41 $81.7$a1$b12$i1990$j12
+
+245 00 $aGet combined holdings, result
+853 20 $81$av.$bno.$u12$vr$i(year)$j(month)$wm$x01
+863 40 $81.1$a1$b1-4$i1990$j01-04
+863 40 $81.2$a1$b6-8$i1990$j06-08
+863 40 $81.3$a1-$b10-$i1990-$j10-