From fbe9e5ae5114f6730996fcba2cfc207192284b4e Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Tue, 7 May 2013 18:23:27 -0400 Subject: [PATCH] Tie in new MFHD method to serials module/MFHD tests for compressing, combining [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 Signed-off-by: Lebbeous Fogle-Weekley --- .../lib/OpenILS/Application/Serial.pm | 4 +-- .../lib/OpenILS/Utils/MFHD/test/mfhd.t | 24 ++++++++++++++ .../lib/OpenILS/Utils/MFHD/test/mfhddata2.txt | 31 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm index d79c5c6eef..c619d37370 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm @@ -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 : "") . " and " . scalar(@$issuances) . " issuances, of which one has ID #" . $issuances->[0]->id; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhd.t b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhd.t index 29ee865a65..97e64fd2d8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhd.t +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhd.t @@ -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; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhddata2.txt b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhddata2.txt index a450bb41f8..65a6fe868f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhddata2.txt +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/test/mfhddata2.txt @@ -19,6 +19,22 @@ 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 @@ -54,4 +70,19 @@ 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- -- 2.43.2