From 9d956358ccaa401917d0b4089a83a5fdc9c7f678 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 17 Jan 2020 05:50:35 -0500 Subject: [PATCH] lp1846354 qa tests Signed-off-by: Jason Etheridge --- .../live_t/14-lp1499123_csp_ignore_proximity.t | 2 +- .../live_t/18-lp1592891_sip_standing_penalties.t | 2 +- .../30-lp1846354_actor_usr_message_penalty.t | 133 +++++++++++++++++++++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/perlmods/live_t/30-lp1846354_actor_usr_message_penalty.t diff --git a/Open-ILS/src/perlmods/live_t/14-lp1499123_csp_ignore_proximity.t b/Open-ILS/src/perlmods/live_t/14-lp1499123_csp_ignore_proximity.t index 709fcb02e0..6201c035e9 100644 --- a/Open-ILS/src/perlmods/live_t/14-lp1499123_csp_ignore_proximity.t +++ b/Open-ILS/src/perlmods/live_t/14-lp1499123_csp_ignore_proximity.t @@ -61,7 +61,7 @@ sub apply_staff_chr_to_patron { $penalty->set_date('now'); $penalty->staff($staff->id()); $penalty->org_unit(1); # Consortium-wide. - $penalty->note('LP 1499123 csp.ignore_proximity test'); + #$penalty->note('LP 1499123 csp.ignore_proximity test'); my $r = $apputils->simplereq( 'open-ils.actor', 'open-ils.actor.user.penalty.apply', 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 ca8754eb19..72e96cf1c1 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 @@ -43,7 +43,7 @@ sub apply_penalty_to_patron { $penalty->set_date('now'); $penalty->staff($staff->id()); $penalty->org_unit(1); # Consortium-wide. - $penalty->note('LP 1592891 SIP standing penalties test'); + #$penalty->note('LP 1592891 SIP standing penalties test'); my $r = $apputils->simplereq( 'open-ils.actor', 'open-ils.actor.user.penalty.apply', diff --git a/Open-ILS/src/perlmods/live_t/30-lp1846354_actor_usr_message_penalty.t b/Open-ILS/src/perlmods/live_t/30-lp1846354_actor_usr_message_penalty.t new file mode 100644 index 0000000000..68e23da7c2 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/30-lp1846354_actor_usr_message_penalty.t @@ -0,0 +1,133 @@ +#!perl +use strict; use warnings; + +use Test::More tests => 12; +use Data::Dumper; + +diag("Test actor.usr_message_penalty feature."); + +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-30-lp1846354_actor_usr_message_penalty.t'; +use constant WORKSTATION_LIB => 4; + +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 retrieve_user_messages { + my $patron = shift; + return $apputils->simplereq( + 'open-ils.pcrud', + 'open-ils.pcrud.search.aum.atomic', + $script->authtoken, + { 'usr' => $patron->id() } + ); +} + +sub apply_staff_chr_to_patron_with_msg { + my $patron = shift; + my $penalty = Fieldmapper::actor::user_standing_penalty->new(); + $penalty->standing_penalty(25); + $penalty->usr($patron->id()); + $penalty->set_date('now'); + $penalty->staff(1); # admin + $penalty->org_unit(1); # Consortium-wide. + my $msg = { + pub => 't', + title => 'lp1846354 test title', + message => 'lp1846354 test message' + }; + my $r = $apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.penalty.apply', + $script->authtoken, + $penalty, + $msg + ); + if (ref($r)) { + undef($penalty); + } else { + $penalty->id($r); + } + return $penalty; +} + +sub remove_staff_chr_from_patron { + my $penalty = shift; + return $apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.penalty.remove', + $script->authtoken, + $penalty + ); +} + +# In concerto, we need to register a workstation. +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff', +}); +ok($script->authtoken, 'Initial Login'); + +SKIP: { + my $ws = $script->find_workstation(WORKSTATION_NAME, WORKSTATION_LIB); + 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'); + +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'); + +# Patron should have no user messages +my $user_messages = retrieve_user_messages($patron); +ok(! scalar(@{$user_messages}), 'Patron has no user messages'); + +# Add the STAFF_CHR to the patron +my $penalty = apply_staff_chr_to_patron_with_msg($patron); +ok(ref $penalty, 'Added STAFF_CHR to patron'); + +# Patron should have one user message +$user_messages = retrieve_user_messages($patron); +ok(scalar(@{$user_messages} == 1), 'Patron has a user message'); + +# It should be public/patron-visible +ok(@{$user_messages}[0]->pub() eq 't', 'User message pub flag is true'); + +# It should be flagged as not deleted +ok(@{$user_messages}[0]->deleted() eq 'f', 'User message is not flagged deleted'); + +# We remove the STAFF_CHR from our test patron. +my $r = remove_staff_chr_from_patron($penalty); +ok( ! ref $r, 'STAFF_CHR removed from patron'); + +# It should be flagged as not deleted +$user_messages = retrieve_user_messages($patron); +ok(@{$user_messages}[0]->deleted() eq 'f', 'User message is not flagged deleted'); +# worth noting that the Remove Note action in the staff client will delete both +# the penalty and its user message + +$script->logout(); -- 2.11.0