[open-ils-commits] [GIT] Evergreen ILS branch master updated. 5e0c9b31d6eb286ecd1614dc26519356fdeca236

Evergreen Git git at git.evergreen-ils.org
Wed Jun 15 20:21:17 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  5e0c9b31d6eb286ecd1614dc26519356fdeca236 (commit)
       via  22536d162f757feaa2fe055d1d6c0b0878dd29ae (commit)
       via  56cc12ef6538e50bea7c1132fc5bee7b8096f5b5 (commit)
      from  e1853b2c4fa9c7c56e22b2bb06cb427dde9cc351 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5e0c9b31d6eb286ecd1614dc26519356fdeca236
Author: Jeff Godin <jgodin at tadl.org>
Date:   Wed Jun 15 12:25:24 2016 -0400

    LP#1592891: Fix SIP2 standing penalty failures
    
    Update too_many_overdue and excessive_fines in OpenILS::SIP::Patron
    to account for the fact that the user object in this context no
    longer contains an array of ausp objects, but just an array of ausp
    IDs.
    
    This fixes SIP2 failures with patron information messages when a
    patron has one or more blocking penalties that are not otherwise
    ignored.
    
    Signed-off-by: Jeff Godin <jgodin at tadl.org>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
index 130d9bf..ad64b61 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
@@ -17,6 +17,7 @@ use Digest::MD5 qw(md5_hex);
 use OpenILS::SIP;
 use OpenILS::Application::AppUtils;
 use OpenILS::Application::Actor;
+use OpenILS::Const qw/:const/;
 use OpenSRF::Utils qw/:datetime/;
 use DateTime::Format::ISO8601;
 my $U = 'OpenILS::Application::AppUtils';
@@ -447,7 +448,7 @@ sub too_many_charged {      # not implemented
 sub too_many_overdue { 
     my $self = shift;
     return scalar( # PATRON_EXCEEDS_OVERDUE_COUNT
-        grep { $_->standing_penalty == 2 } @{$self->{user}->standing_penalties}
+        grep { $_ == OILS_PENALTY_PATRON_EXCEEDS_OVERDUE_COUNT } @{$self->{user}->standing_penalties}
     );
 }
 
@@ -472,7 +473,7 @@ sub too_many_lost {
 sub excessive_fines { 
     my $self = shift;
     return scalar( # PATRON_EXCEEDS_FINES
-        grep { $_->standing_penalty == 1 } @{$self->{user}->standing_penalties}
+        grep { $_ == OILS_PENALTY_PATRON_EXCEEDS_FINES } @{$self->{user}->standing_penalties}
     );
 }
 

commit 22536d162f757feaa2fe055d1d6c0b0878dd29ae
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Wed Jun 15 20:16:52 2016 -0400

    LP#1592891: tweak tests
    
    This patch wraps the standing penalty checks in evals so that if they
    crash, the test script can carry on -- and make it to the point where
    it cleans up the standing penalties it adds.
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t b/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t
index 7791cd3..bf695bc 100644
--- a/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t
+++ b/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t
@@ -92,13 +92,27 @@ sub patron_sip_test {
 sub patron_sip_too_many_overdue_test {
     my $patron_id = shift;
     my $patron = OpenILS::SIP::Patron->new(usr => $patron_id, authtoken => $script->authtoken);
-    return $patron->too_many_overdue;
+    my $rv;
+    eval { $rv = $patron->too_many_overdue };
+    if ($@) {
+        diag('$patron->too_many_overdue crashed: ' . $@);
+        return;
+    } else {
+        return $rv;
+    }
 }
 
 sub patron_sip_excessive_fines_test {
     my $patron_id = shift;
     my $patron = OpenILS::SIP::Patron->new(usr => $patron_id, authtoken => $script->authtoken);
-    return $patron->excessive_fines;
+    my $rv;
+    eval { $rv = $patron->excessive_fines };
+    if ($@) {
+        diag('$patron->excessive_fines crashed: ' . $@);
+        return;
+    } else {
+        return $rv;
+    }
 }
 
 # In concerto, we need to register a workstation.

commit 56cc12ef6538e50bea7c1132fc5bee7b8096f5b5
Author: Jeff Godin <jgodin at tadl.org>
Date:   Wed Jun 15 13:46:09 2016 -0400

    LP#1592891: Tests - SIP2 standing penalty failures
    
    Tests for SIP2 standing penalty failures in LP#1592891
    
    Much of the code in these tests was copied or adapted from Jason
    Stephenson's tests in 14-lp1499123_csp_ignore_proximity.t
    
    Signed-off-by: Jeff Godin <jgodin at tadl.org>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t b/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t
new file mode 100644
index 0000000..7791cd3
--- /dev/null
+++ b/Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t
@@ -0,0 +1,190 @@
+#!perl
+use strict;
+use warnings;
+
+use Test::More tests => 30;
+
+# This test includes much code copied or adapted from Jason Stephenson's tests
+# in 14-lp1499123_csp_ignore_proximity.t
+
+diag("Test bugfix for lp1592891 - SIP2 failures with standing penalties.");
+
+use OpenILS::Const qw/:const/;
+use OpenILS::Utils::TestUtils;
+use OpenILS::SIP::Patron;
+my $script = OpenILS::Utils::TestUtils->new();
+our $apputils = 'OpenILS::Application::AppUtils';
+
+use constant WORKSTATION_NAME => 'BR1-test-lp1592891_sip_standing_penalties.t';
+use constant WORKSTATION_LIB => 4;
+
+# Because this may run multiple times, without a DB reload, we search
+# for the workstation before registering it.
+sub find_workstation {
+    my $r = $apputils->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.workstation.list',
+        $script->authtoken,
+        WORKSTATION_LIB
+    );
+    if ($r->{&WORKSTATION_LIB}) {
+        return scalar(grep {$_->name() eq WORKSTATION_NAME} @{$r->{&WORKSTATION_LIB}});
+    }
+    return 0;
+}
+
+sub retrieve_penalty {
+    my $e = shift;
+    my $penalty = shift;
+    my $csp = $e->retrieve_config_standing_penalty($penalty);
+    return $csp;
+}
+
+sub retrieve_user_by_barcode {
+    my $barcode = shift;
+    return $apputils->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.user.fleshed.retrieve_by_barcode',
+        $script->authtoken,
+        $barcode
+    );
+}
+
+sub apply_penalty_to_patron {
+    my ($staff, $patron, $penalty_id) = @_;
+    my $penalty = Fieldmapper::actor::user_standing_penalty->new();
+    $penalty->standing_penalty($penalty_id);
+    $penalty->usr($patron->id());
+    $penalty->set_date('now');
+    $penalty->staff($staff->id());
+    $penalty->org_unit(1); # Consortium-wide.
+    $penalty->note('LP 1592891 SIP standing penalties test');
+    my $r = $apputils->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.user.penalty.apply',
+        $script->authtoken,
+        $penalty
+    );
+    if (ref($r)) {
+        undef($penalty);
+    } else {
+        $penalty->id($r);
+    }
+    return $penalty;
+}
+
+sub remove_penalty_from_patron {
+    my $penalty = shift;
+    return $apputils->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.user.penalty.remove',
+        $script->authtoken,
+        $penalty
+    );
+}
+
+sub patron_sip_test {
+    my $patron_id = shift;
+    my $patron = OpenILS::SIP::Patron->new(usr => $patron_id, authtoken => $script->authtoken);
+    return scalar(@{$patron->{user}->standing_penalties()});
+}
+
+sub patron_sip_too_many_overdue_test {
+    my $patron_id = shift;
+    my $patron = OpenILS::SIP::Patron->new(usr => $patron_id, authtoken => $script->authtoken);
+    return $patron->too_many_overdue;
+}
+
+sub patron_sip_excessive_fines_test {
+    my $patron_id = shift;
+    my $patron = OpenILS::SIP::Patron->new(usr => $patron_id, authtoken => $script->authtoken);
+    return $patron->excessive_fines;
+}
+
+# In concerto, we need to register a workstation.
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff',
+});
+ok($script->authtoken, 'Initial Login');
+
+SKIP: {
+    my $ws = find_workstation();
+    skip 'Workstation exists', 1 if ($ws);
+    $ws = $script->register_workstation(WORKSTATION_NAME, WORKSTATION_LIB) unless ($ws);
+    ok(! ref $ws, 'Registered a new workstation');
+}
+
+$script->logout();
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff',
+    workstation => WORKSTATION_NAME
+});
+ok($script->authtoken, 'Login with workstaion');
+
+# Get a CStoreEditor for later use.
+my $editor = $script->editor(authtoken=>$script->authtoken);
+my $staff = $editor->checkauth();
+ok(ref($staff), 'Got a staff user');
+
+# We retrieve STAFF_CHR penalty and check that it has an undefined
+# ignore_proximity.
+my $staff_chr = retrieve_penalty($editor, 25);
+isa_ok($staff_chr, 'Fieldmapper::config::standing_penalty', 'STAFF_CHR');
+is($staff_chr->name, 'STAFF_CHR', 'Penalty name is STAFF_CHR');
+is($staff_chr->ignore_proximity, undef, 'STAFF_CHR ignore_proximity is undefined');
+
+# We retrieve OILS_PENALTY_PATRON_EXCEEDS_FINES penalty and check that it has an undefined
+# ignore_proximity.
+my $csp_fines = retrieve_penalty($editor, OILS_PENALTY_PATRON_EXCEEDS_FINES);
+isa_ok($csp_fines, 'Fieldmapper::config::standing_penalty', 'PATRON_EXCEEDS_FINES');
+is($csp_fines->name, 'PATRON_EXCEEDS_FINES', 'Penalty name is PATRON_EXCEEDS_FINES');
+is($csp_fines->ignore_proximity, undef, 'PATRON_EXCEEDS_FINES ignore_proximity is undefined');
+
+# We retrieve STAFF_CHR penalty and check that it has an undefined
+# ignore_proximity.
+my $csp_overdues = retrieve_penalty($editor, OILS_PENALTY_PATRON_EXCEEDS_OVERDUE_COUNT);
+isa_ok($csp_overdues, 'Fieldmapper::config::standing_penalty', 'PATRON_EXCEEDS_OVERDUE_COUNT');
+is($csp_overdues->name, 'PATRON_EXCEEDS_OVERDUE_COUNT', 'Penalty name is PATRON_EXCEEDS_OVERDUE_COUNT');
+is($csp_overdues->ignore_proximity, undef, 'PATRON_EXCEEDS_OVERDUE_COUNT ignore_proximity is undefined');
+
+# We need a patron with no penalties to test holds and circulation.
+my $patron = retrieve_user_by_barcode("99999350419");
+isa_ok($patron, 'Fieldmapper::actor::user', 'Patron');
+
+# Patron should have no penalties.
+ok(! scalar(@{$patron->standing_penalties()}), 'Patron has no penalties');
+is(patron_sip_test($patron->id()), 0, 'SIP says patron has no penalties');
+is(patron_sip_too_many_overdue_test($patron->id()), 0, 'SIP says patron does not have too many overdues');
+is(patron_sip_excessive_fines_test($patron->id()), 0, 'SIP says patron does not have excessive fines');
+
+# Add STAFF_CHR penalty to the patron
+my $penalty = apply_penalty_to_patron($staff, $patron, 25);
+ok(ref $penalty, 'Added STAFF_CHR penalty to patron');
+is(patron_sip_test($patron->id()), 1, 'SIP says patron has one penalty');
+
+# Add PATRON_EXCEEDS_FINES penalty to the patron
+my $fines_penalty = apply_penalty_to_patron($staff, $patron, OILS_PENALTY_PATRON_EXCEEDS_FINES);
+ok(ref $fines_penalty, 'Added PATRON_EXCEEDS_FINES penalty to patron');
+is(patron_sip_test($patron->id()), 2, 'SIP says patron has two penalties');
+is(patron_sip_excessive_fines_test($patron->id()), 1, 'SIP says patron has excessive fines');
+
+# Add PATRON_EXCEEDS_OVERDUE_COUNT penalty to the patron
+my $overdues_penalty = apply_penalty_to_patron($staff, $patron, OILS_PENALTY_PATRON_EXCEEDS_OVERDUE_COUNT);
+ok(ref $overdues_penalty, 'Added PATRON_EXCEEDS_OVERDUE_COUNT penalty to patron');
+is(patron_sip_test($patron->id()), 3, 'SIP says patron has three penalties');
+is(patron_sip_excessive_fines_test($patron->id()), 1, 'SIP says patron has excessive fines');
+is(patron_sip_too_many_overdue_test($patron->id()), 1, 'SIP says patron has too many overdues');
+
+# We remove the penalties from our test patron.
+my $r = remove_penalty_from_patron($penalty);
+ok( ! ref $r, 'STAFF_CHR removed from patron');
+my $r_fines = remove_penalty_from_patron($fines_penalty);
+ok( ! ref $r_fines, 'PATRON_EXCEEDS_FINES removed from patron');
+my $r_overdues = remove_penalty_from_patron($overdues_penalty);
+ok( ! ref $r_overdues, 'PATRON_EXCEEDS_OVERDUE_COUNT removed from patron');
+
+$script->logout();

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm    |    5 +-
 .../live_t/18-lp1592891_sip_standing_penalties.t   |  204 ++++++++++++++++++++
 2 files changed, 207 insertions(+), 2 deletions(-)
 create mode 100644 Open-ILS/src/perlmods/live_t/18-lp1592891_sip_standing_penalties.t


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list