From: Jason Stephenson Date: Sun, 27 Mar 2016 00:16:34 +0000 (-0400) Subject: LP 1562426: Renumber Perl live_t tests. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7c32948a761409fca0f6dd324c9f1b23bd2e93cc;p=working%2FEvergreen.git LP 1562426: Renumber Perl live_t tests. We had some overlap in numbers at the beginning of test file names. The OCD in me think this should be straightened out. This branch renumbers the duplicates starting with 10-. Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/perlmods/live_t/10-lp1481036-future-backdate.t b/Open-ILS/src/perlmods/live_t/10-lp1481036-future-backdate.t deleted file mode 100644 index a2490939c6..0000000000 --- a/Open-ILS/src/perlmods/live_t/10-lp1481036-future-backdate.t +++ /dev/null @@ -1,36 +0,0 @@ -#!perl -use strict; use warnings; - -use Test::More tests => 3; - -diag("Tests handling of future backdates in checkin"); - -use constant ITEM_BARCODE => 'CONC4000070'; - -use DateTime; -use OpenILS::Utils::TestUtils; -my $script = OpenILS::Utils::TestUtils->new(); -$script->bootstrap; - -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff' -}); - -ok($script->authtoken, 'Have an authtoken'); - -my $checkin_resp = $script->do_checkin({ - barcode => ITEM_BARCODE, - backdate => '3001-01-23' # date of the singularity; it is known. -}); - -is(ref $checkin_resp,'HASH','Checkin request returned a HASH'); - -my $ymd = DateTime->now->strftime('%F'); - -ok( - substr($checkin_resp->{payload}->{circ}->checkin_time, 0, 10) eq $ymd, - 'Checkin time matches current date, not backdate' -); - diff --git a/Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t b/Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t deleted file mode 100644 index e24888bc1d..0000000000 --- a/Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t +++ /dev/null @@ -1,38 +0,0 @@ -#!perl - -use Test::More tests => 2; - -diag("Make sure we don't close xacts with fines"); - -use strict; -use warnings; - -use OpenILS::Utils::TestUtils; -my $script = OpenILS::Utils::TestUtils->new(); -#our $apputils = "OpenILS::Application::AppUtils"; -my $storage_ses = $script->session('open-ils.storage'); -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff'}); -ok( $script->authtoken, 'Have an authtoken'); - -my $barcode = 'CONC4000054'; -my $circ_id = 18; - -my $checkin_resp = $script->do_checkin_override({ - barcode => $barcode}); - -my $circ_req = $storage_ses->request('open-ils.storage.direct.action.circulation.retrieve', $circ_id); -if (my $circ_resp = $circ_req->recv) { - if (my $circ = $circ_resp->content) { - ok( - !$circ->xact_finish, - 'Circ with id = ' . $circ_id . ' is overdue with fines, so xact_finish isn\'t set' - ); - } else { - fail('unable to retrieve circ'); - } -} - -$script->logout(); diff --git a/Open-ILS/src/perlmods/live_t/11-lp1240119-safe-token-activity.t b/Open-ILS/src/perlmods/live_t/11-lp1240119-safe-token-activity.t deleted file mode 100644 index 99094509cc..0000000000 --- a/Open-ILS/src/perlmods/live_t/11-lp1240119-safe-token-activity.t +++ /dev/null @@ -1,43 +0,0 @@ -#!perl -use strict; use warnings; -use Test::More tests => 4; -use OpenILS::Utils::TestUtils; -use OpenILS::Utils::CStoreEditor qw/:funcs/; - -diag("Tests safe auth token user activity tracking"); - -my $script = OpenILS::Utils::TestUtils->new(); -$script->bootstrap; - -my $e = new_editor(); -$e->init; - -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff' -}); - -ok($script->authtoken, 'Have an authtoken'); - -my $actor_ses = $script->session('open-ils.actor'); -my $req = $actor_ses->request( - 'open-ils.actor.session.safe_token', $script->authtoken); - -my $safe_token = $req->recv->content; - -ok($safe_token, 'Have safe token'); - -my $act_count = scalar(@{$e->search_actor_usr_activity({usr => 1})}); - -$req = $actor_ses->request( - 'open-ils.actor.safe_token.home_lib.shortname', $safe_token); - -my $home_ou = $req->recv->content; - -ok($home_ou, 'Retrieved home org unit'); - -my $act_count2 = scalar(@{$e->search_actor_usr_activity({usr => 1})}); - -is($act_count2, $act_count + 1, 'User activity entry created'); - diff --git a/Open-ILS/src/perlmods/live_t/11-lp1481036-future-backdate.t b/Open-ILS/src/perlmods/live_t/11-lp1481036-future-backdate.t new file mode 100644 index 0000000000..a2490939c6 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/11-lp1481036-future-backdate.t @@ -0,0 +1,36 @@ +#!perl +use strict; use warnings; + +use Test::More tests => 3; + +diag("Tests handling of future backdates in checkin"); + +use constant ITEM_BARCODE => 'CONC4000070'; + +use DateTime; +use OpenILS::Utils::TestUtils; +my $script = OpenILS::Utils::TestUtils->new(); +$script->bootstrap; + +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff' +}); + +ok($script->authtoken, 'Have an authtoken'); + +my $checkin_resp = $script->do_checkin({ + barcode => ITEM_BARCODE, + backdate => '3001-01-23' # date of the singularity; it is known. +}); + +is(ref $checkin_resp,'HASH','Checkin request returned a HASH'); + +my $ymd = DateTime->now->strftime('%F'); + +ok( + substr($checkin_resp->{payload}->{circ}->checkin_time, 0, 10) eq $ymd, + 'Checkin time matches current date, not backdate' +); + diff --git a/Open-ILS/src/perlmods/live_t/12-lp1484989_dont_close_fined_xacts.t b/Open-ILS/src/perlmods/live_t/12-lp1484989_dont_close_fined_xacts.t new file mode 100644 index 0000000000..e24888bc1d --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/12-lp1484989_dont_close_fined_xacts.t @@ -0,0 +1,38 @@ +#!perl + +use Test::More tests => 2; + +diag("Make sure we don't close xacts with fines"); + +use strict; +use warnings; + +use OpenILS::Utils::TestUtils; +my $script = OpenILS::Utils::TestUtils->new(); +#our $apputils = "OpenILS::Application::AppUtils"; +my $storage_ses = $script->session('open-ils.storage'); +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff'}); +ok( $script->authtoken, 'Have an authtoken'); + +my $barcode = 'CONC4000054'; +my $circ_id = 18; + +my $checkin_resp = $script->do_checkin_override({ + barcode => $barcode}); + +my $circ_req = $storage_ses->request('open-ils.storage.direct.action.circulation.retrieve', $circ_id); +if (my $circ_resp = $circ_req->recv) { + if (my $circ = $circ_resp->content) { + ok( + !$circ->xact_finish, + 'Circ with id = ' . $circ_id . ' is overdue with fines, so xact_finish isn\'t set' + ); + } else { + fail('unable to retrieve circ'); + } +} + +$script->logout(); diff --git a/Open-ILS/src/perlmods/live_t/12-lp1499123_csp_ignore_proximity.t b/Open-ILS/src/perlmods/live_t/12-lp1499123_csp_ignore_proximity.t deleted file mode 100644 index 2b993bcfeb..0000000000 --- a/Open-ILS/src/perlmods/live_t/12-lp1499123_csp_ignore_proximity.t +++ /dev/null @@ -1,252 +0,0 @@ -#!perl -use strict; use warnings; - -use Test::More tests => 28; -use Data::Dumper; - -diag("Test config.standing_penalty.ignore_proximity 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-lp1499123_csp_ignore_proximity.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_staff_chr { - my $e = shift; - my $staff_chr = $e->retrieve_config_standing_penalty(25); - return $staff_chr; -} - -sub update_staff_chr { - my $e = shift; - my $penalty = shift; - $e->xact_begin; - my $r = $e->update_config_standing_penalty($penalty) || $e->event(); - if (ref($r)) { - $e->rollback(); - } else { - $e->commit; - } - return $r; -} - -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_copy_by_barcode { - my $editor = shift; - my $barcode = shift; - my $r = $editor->search_asset_copy({barcode => $barcode}); - if (ref($r) eq 'ARRAY' && @$r) { - return $r->[0]; - } - return undef; -} - -sub apply_staff_chr_to_patron { - my ($staff, $patron) = @_; - my $penalty = Fieldmapper::actor::user_standing_penalty->new(); - $penalty->standing_penalty(25); - $penalty->usr($patron->id()); - $penalty->set_date('now'); - $penalty->staff($staff->id()); - $penalty->org_unit(1); # Consortium-wide. - $penalty->note('LP 1499123 csp.ignore_proximity 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_staff_chr_from_patron { - my $penalty = shift; - return $apputils->simplereq( - 'open-ils.actor', - 'open-ils.actor.user.penalty.remove', - $script->authtoken, - $penalty - ); -} - -sub checkout_permit_test { - my $patron = shift; - my $copy_barcode = shift; - my $r = $apputils->simplereq( - 'open-ils.circ', - 'open-ils.circ.checkout.permit', - $script->authtoken, - { - patron => $patron->id(), - barcode => $copy_barcode - } - ); - if (ref($r) eq 'HASH' && $r->{textcode} eq 'SUCCESS') { - return 1; - } - return 0; -} - -sub copy_hold_permit_test { - my $editor = shift; - my $patron = shift; - my $copy_barcode = shift; - my $copy = retrieve_copy_by_barcode($editor, $copy_barcode); - if ($copy) { - my $r = $apputils->simplereq( - 'open-ils.circ', - 'open-ils.circ.title_hold.is_possible', - $script->authtoken, - { - patronid => $patron->id(), - pickup_lib => 4, - copy_id => $copy->id(), - hold_type => 'C' - } - ); - if (ref($r) && defined $r->{success}) { - return $r->{success}; - } - } - return undef; -} - -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()}); -} - -# 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 block and check that it has an undefined -# ignore_proximity. -my $staff_chr = retrieve_staff_chr($editor); -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 set the ignore_proximity to 0. -$staff_chr->ignore_proximity(0); -ok(! ref update_staff_chr($editor, $staff_chr), 'Update of STAFF_CHR'); - -# 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'); - -# Add the STAFF_CHR to the patron -my $penalty = apply_staff_chr_to_patron($staff, $patron); -ok(ref $penalty, 'Added STAFF_CHR to patron'); -is(patron_sip_test($patron->id()), 0, 'SIP says patron has no penalties'); - -# See if we can place a hold on a copy owned by BR1. -is(copy_hold_permit_test($editor, $patron, "CONC4300036"), 1, 'Can place hold on copy from BR1'); -# We should not be able to place a hold on a copy owned by a different branch. -is(copy_hold_permit_test($editor, $patron, "CONC51000636"), 0, 'Cannot place hold on copy from BR2'); - -# See if we can check out a copy owned by branch 4 out to the patron. -# This should succeed. -ok(checkout_permit_test($patron, "CONC4300036"), 'Can checkout copy from BR1'); - -# We should not be able to checkout a copy owned by a different branch. -ok(!checkout_permit_test($patron, "CONC51000636"), 'Cannot checkout copy from BR2'); - -# We reset the ignore_proximity of STAFF_CHR. -$staff_chr->clear_ignore_proximity(); -ok(! ref update_staff_chr($editor, $staff_chr), 'Reset of STAFF_CHR'); -is(patron_sip_test($patron->id()), 1, 'SIP says patron has one penalty'); - -# See if we can place a hold on a copy owned by BR1. -is(copy_hold_permit_test($editor, $patron, "CONC4300036"), 0, 'Cannot place hold on copy from BR1'); -# We should not be able to place a hold on a copy owned by a different branch. -is(copy_hold_permit_test($editor, $patron, "CONC51000636"), 0, 'Cannot place hold on copy from BR2'); - -# See if we can check out a copy owned by branch 4 out to the patron. -# This should succeed. -ok(!checkout_permit_test($patron, "CONC4300036"), 'Cannot checkout copy from BR1'); - -# We should not be able to checkout a copy owned by a different branch. -ok(!checkout_permit_test($patron, "CONC51000636"), 'Cannot checkout copy from BR2'); - -# 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'); - -# Do the checks again, all should pass. -is(patron_sip_test($patron->id()), 0, 'SIP says patron has no penalties'); - -# See if we can place a hold on a copy owned by BR1. -is(copy_hold_permit_test($editor, $patron, "CONC4300036"), 1, 'Can place hold on copy from BR1'); -# We should now be able to place a hold on a copy owned by a different branch. -is(copy_hold_permit_test($editor, $patron, "CONC51000636"), 1, 'Can place hold on copy from BR2'); - -# See if we can check out a copy owned by branch 4 out to the patron. -# This should succeed. -ok(checkout_permit_test($patron, "CONC4300036"), 'Can checkout copy from BR1'); - -# We should not be able to checkout a copy owned by a different branch. -ok(checkout_permit_test($patron, "CONC51000636"), 'Can checkout copy from BR2'); - -$script->logout(); diff --git a/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t b/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t deleted file mode 100644 index 31b69ab246..0000000000 --- a/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t +++ /dev/null @@ -1,174 +0,0 @@ -#!perl - -use Test::More tests => 12; - -diag("Test checking for, creating, and restricting patron opt-in."); - -use constant WORKSTATION_NAME => 'BR1-test-12-lp1533329-opt-in.t'; -use constant WORKSTATION_LIB => 4; # BR1, a branch of SYS1 -use constant PATRON_LIB => 6; # BR3, a branch of SYS2 -use constant PATRON_SYS => 3; # SYS2 -use constant SYS_DEPTH => 1; # depth of "System" org type -use constant PATRON_BARCODE => '99999359616'; - -use strict; use warnings; - -use OpenILS::Utils::TestUtils; -use OpenILS::Utils::CStoreEditor qw/:funcs/; -use OpenILS::Utils::Fieldmapper; - -my $script = OpenILS::Utils::TestUtils->new(); -$script->bootstrap; - -our $U = "OpenILS::Application::AppUtils"; - -my $e = new_editor(xact => 1); -$e->init; - -# initialize a new aous object for insertion into the db -sub new_org_setting { - my ($org_unit, $name, $value) = @_; - my $set = Fieldmapper::actor::org_unit_setting->new(); - $set->org_unit($org_unit); - $set->name($name); - $set->value($value); - return $set; -} - -sub opt_in_enabled { - my $resp = $U->simplereq( - 'open-ils.actor', - 'open-ils.actor.user.org_unit_opt_in.enabled' - ); - return $resp; -} - -# do an opt-in check -sub opt_in_check { - my ($authtoken, $usr_id) = @_; - my $resp = $U->simplereq( - 'open-ils.actor', - 'open-ils.actor.user.org_unit_opt_in.check', - $authtoken, $usr_id); - return $resp; -} - -unless(opt_in_enabled()) { - BAIL_OUT('cannot test opt-in unless enabled in opensrf.xml'); -} - -#---------------------------------------------------------------- -# 1. Login, register workstation, get authtoken. -#---------------------------------------------------------------- -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff'}); -ok( - $script->authtoken, - 'Have an authtoken' -); -my $ws = $script->register_workstation(WORKSTATION_NAME,WORKSTATION_LIB); -ok( - ! ref $ws, - 'Registered a new workstation' -); -$script->logout(); -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff', - workstation => WORKSTATION_NAME}); -ok( - $script->authtoken, - 'Have an authtoken associated with the workstation' -); - -#---------------------------------------------------------------- -# 2. Set org.patron_opt_boundary for SYS2, so that BR1 is outside -# the boundary. -#---------------------------------------------------------------- -$e->xact_begin; -my $boundary = new_org_setting(PATRON_SYS, 'org.patron_opt_boundary', SYS_DEPTH); -my $boundary_stat = $e->create_actor_org_unit_setting($boundary); -ok($boundary_stat, 'Opt boundary setting created successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 3. Check opt-in for test patron. It should return 0. -#---------------------------------------------------------------- -my $patron = $U->fetch_user_by_barcode(PATRON_BARCODE); -is( - opt_in_check($script->authtoken, $patron->id), - '0', - 'Opt-in check for non-opted-in patron correctly returned 0' -); - -#---------------------------------------------------------------- -# 4. Set org.restrict_opt_to_depth at SYS2, so that BR1 is -# outside SYS2's section of the tree at the specified depth (thus -# preventing opt-in). -#---------------------------------------------------------------- -$e->xact_begin; -my $restrict = new_org_setting(PATRON_SYS, 'org.restrict_opt_to_depth', SYS_DEPTH); -my $restrict_stat = $e->create_actor_org_unit_setting($restrict); -ok($restrict_stat, 'Opt restrict depth setting created successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 5. Check opt-in for test patron. It should return 2. -#---------------------------------------------------------------- -is( - opt_in_check($script->authtoken, $patron->id), - '2', - 'Opt-in check for patron at restricted opt-in library correctly returned 2' -); - -#---------------------------------------------------------------- -# 6. Remove the org.restrict_opt_to_depth setting for SYS2. -#---------------------------------------------------------------- -$e->xact_begin; -my $delete_restrict_stat = $e->delete_actor_org_unit_setting($restrict); -ok($delete_restrict_stat, 'Opt restrict depth setting deleted successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 7. Create opt-in for test patron. -#---------------------------------------------------------------- -my $opt_id = $U->simplereq( - 'open-ils.actor', - 'open-ils.actor.user.org_unit_opt_in.create', - $script->authtoken, $patron->id, WORKSTATION_LIB); -ok($opt_id, 'Patron successfully opted in'); - -#---------------------------------------------------------------- -# 8. Check opt-in for test patron. It should return 1. -#---------------------------------------------------------------- -is( - opt_in_check($script->authtoken, $patron->id), - '1', - 'Opt-in check for opted-in patron correctly returned 1' -); - -#---------------------------------------------------------------- -# 9. Delete opt-in. -#---------------------------------------------------------------- -my $opt = $U->simplereq( - 'open-ils.cstore', - 'open-ils.cstore.direct.actor.usr_org_unit_opt_in.retrieve', - $opt_id -); -$e->xact_begin; -my $delete_opt_stat = $e->delete_actor_usr_org_unit_opt_in($opt); -ok($delete_opt_stat, 'Opt-in deleted successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 10. Remove opt boundary setting. -#---------------------------------------------------------------- -$e->xact_begin; -my $delete_setting_stat = $e->delete_actor_org_unit_setting($boundary); -ok($delete_setting_stat, 'Opt boundary setting deleted successfully'); -$e->xact_commit; - - diff --git a/Open-ILS/src/perlmods/live_t/13-acq-invoicing.t b/Open-ILS/src/perlmods/live_t/13-acq-invoicing.t deleted file mode 100644 index 82f9ec0982..0000000000 --- a/Open-ILS/src/perlmods/live_t/13-acq-invoicing.t +++ /dev/null @@ -1,88 +0,0 @@ -#!perl -use strict; use warnings; -use Test::More tests => 7; -use OpenILS::Utils::TestUtils; -use OpenILS::Utils::CStoreEditor qw/:funcs/; - -diag("Tests ACQ invoices"); - -my $script = OpenILS::Utils::TestUtils->new(); -$script->bootstrap; - -my $e = new_editor(); -$e->init; - -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff' -}); - -ok($script->authtoken, 'Have an authtoken'); - -my $invoice = Fieldmapper::acq::invoice->new; -$invoice->isnew(1); -$invoice->receiver(1); -$invoice->provider(1); -$invoice->shipper(1); -$invoice->inv_ident(rand()); -$invoice->complete('f'); - -my $entry = Fieldmapper::acq::invoice_entry->new; -$entry->isnew(1); -$entry->lineitem(3); -$entry->purchase_order(2); -$entry->inv_item_count(1); -$entry->phys_item_count(1); -$entry->cost_billed('25.00'); -$entry->actual_cost('25.00'); -$entry->amount_paid('25.00'); - -my $acq_ses = $script->session('open-ils.acq'); - -my $req = $acq_ses->request( - 'open-ils.acq.invoice.update', $script->authtoken, $invoice, [$entry]); - -$invoice = $req->recv->content; -$entry = $invoice->entries->[0]; - -is(ref $invoice, 'Fieldmapper::acq::invoice', 'Invoice created'); - -my $inv_debit = - $e->search_acq_fund_debit({invoice_entry => $entry->id})->[0]; - -isnt($inv_debit, undef, 'A fund_debit links to new invoice entry'); - -is($inv_debit->encumbrance, 't', - 'Debit is still encumbered after invoice create'); - -# Close the invoice. LP#1333254. -$invoice->complete('t'); -$invoice->ischanged(1); - -$req = $acq_ses->request( - 'open-ils.acq.invoice.update', $script->authtoken, $invoice); - -$invoice = $req->recv->content; - -is($invoice->complete, 't', 'Invoice is closed'); - -$inv_debit = $e->retrieve_acq_fund_debit($inv_debit->id); - -is($inv_debit->encumbrance, 'f', - 'Debit is disencumbered after invoice close'); - -# re-open the invoice -$invoice->complete('f'); -$invoice->ischanged(1); - -$req = $acq_ses->request( - 'open-ils.acq.invoice.update', $script->authtoken, $invoice); - -$invoice = $req->recv->content; - -$inv_debit = $e->retrieve_acq_fund_debit($inv_debit->id); - -is($inv_debit->encumbrance, 't', - 'Debit is re-encumbered when invoice is reopened'); - diff --git a/Open-ILS/src/perlmods/live_t/13-lp1240119-safe-token-activity.t b/Open-ILS/src/perlmods/live_t/13-lp1240119-safe-token-activity.t new file mode 100644 index 0000000000..99094509cc --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/13-lp1240119-safe-token-activity.t @@ -0,0 +1,43 @@ +#!perl +use strict; use warnings; +use Test::More tests => 4; +use OpenILS::Utils::TestUtils; +use OpenILS::Utils::CStoreEditor qw/:funcs/; + +diag("Tests safe auth token user activity tracking"); + +my $script = OpenILS::Utils::TestUtils->new(); +$script->bootstrap; + +my $e = new_editor(); +$e->init; + +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff' +}); + +ok($script->authtoken, 'Have an authtoken'); + +my $actor_ses = $script->session('open-ils.actor'); +my $req = $actor_ses->request( + 'open-ils.actor.session.safe_token', $script->authtoken); + +my $safe_token = $req->recv->content; + +ok($safe_token, 'Have safe token'); + +my $act_count = scalar(@{$e->search_actor_usr_activity({usr => 1})}); + +$req = $actor_ses->request( + 'open-ils.actor.safe_token.home_lib.shortname', $safe_token); + +my $home_ou = $req->recv->content; + +ok($home_ou, 'Retrieved home org unit'); + +my $act_count2 = scalar(@{$e->search_actor_usr_activity({usr => 1})}); + +is($act_count2, $act_count + 1, 'User activity entry created'); + 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 new file mode 100644 index 0000000000..2b993bcfeb --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/14-lp1499123_csp_ignore_proximity.t @@ -0,0 +1,252 @@ +#!perl +use strict; use warnings; + +use Test::More tests => 28; +use Data::Dumper; + +diag("Test config.standing_penalty.ignore_proximity 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-lp1499123_csp_ignore_proximity.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_staff_chr { + my $e = shift; + my $staff_chr = $e->retrieve_config_standing_penalty(25); + return $staff_chr; +} + +sub update_staff_chr { + my $e = shift; + my $penalty = shift; + $e->xact_begin; + my $r = $e->update_config_standing_penalty($penalty) || $e->event(); + if (ref($r)) { + $e->rollback(); + } else { + $e->commit; + } + return $r; +} + +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_copy_by_barcode { + my $editor = shift; + my $barcode = shift; + my $r = $editor->search_asset_copy({barcode => $barcode}); + if (ref($r) eq 'ARRAY' && @$r) { + return $r->[0]; + } + return undef; +} + +sub apply_staff_chr_to_patron { + my ($staff, $patron) = @_; + my $penalty = Fieldmapper::actor::user_standing_penalty->new(); + $penalty->standing_penalty(25); + $penalty->usr($patron->id()); + $penalty->set_date('now'); + $penalty->staff($staff->id()); + $penalty->org_unit(1); # Consortium-wide. + $penalty->note('LP 1499123 csp.ignore_proximity 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_staff_chr_from_patron { + my $penalty = shift; + return $apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.penalty.remove', + $script->authtoken, + $penalty + ); +} + +sub checkout_permit_test { + my $patron = shift; + my $copy_barcode = shift; + my $r = $apputils->simplereq( + 'open-ils.circ', + 'open-ils.circ.checkout.permit', + $script->authtoken, + { + patron => $patron->id(), + barcode => $copy_barcode + } + ); + if (ref($r) eq 'HASH' && $r->{textcode} eq 'SUCCESS') { + return 1; + } + return 0; +} + +sub copy_hold_permit_test { + my $editor = shift; + my $patron = shift; + my $copy_barcode = shift; + my $copy = retrieve_copy_by_barcode($editor, $copy_barcode); + if ($copy) { + my $r = $apputils->simplereq( + 'open-ils.circ', + 'open-ils.circ.title_hold.is_possible', + $script->authtoken, + { + patronid => $patron->id(), + pickup_lib => 4, + copy_id => $copy->id(), + hold_type => 'C' + } + ); + if (ref($r) && defined $r->{success}) { + return $r->{success}; + } + } + return undef; +} + +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()}); +} + +# 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 block and check that it has an undefined +# ignore_proximity. +my $staff_chr = retrieve_staff_chr($editor); +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 set the ignore_proximity to 0. +$staff_chr->ignore_proximity(0); +ok(! ref update_staff_chr($editor, $staff_chr), 'Update of STAFF_CHR'); + +# 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'); + +# Add the STAFF_CHR to the patron +my $penalty = apply_staff_chr_to_patron($staff, $patron); +ok(ref $penalty, 'Added STAFF_CHR to patron'); +is(patron_sip_test($patron->id()), 0, 'SIP says patron has no penalties'); + +# See if we can place a hold on a copy owned by BR1. +is(copy_hold_permit_test($editor, $patron, "CONC4300036"), 1, 'Can place hold on copy from BR1'); +# We should not be able to place a hold on a copy owned by a different branch. +is(copy_hold_permit_test($editor, $patron, "CONC51000636"), 0, 'Cannot place hold on copy from BR2'); + +# See if we can check out a copy owned by branch 4 out to the patron. +# This should succeed. +ok(checkout_permit_test($patron, "CONC4300036"), 'Can checkout copy from BR1'); + +# We should not be able to checkout a copy owned by a different branch. +ok(!checkout_permit_test($patron, "CONC51000636"), 'Cannot checkout copy from BR2'); + +# We reset the ignore_proximity of STAFF_CHR. +$staff_chr->clear_ignore_proximity(); +ok(! ref update_staff_chr($editor, $staff_chr), 'Reset of STAFF_CHR'); +is(patron_sip_test($patron->id()), 1, 'SIP says patron has one penalty'); + +# See if we can place a hold on a copy owned by BR1. +is(copy_hold_permit_test($editor, $patron, "CONC4300036"), 0, 'Cannot place hold on copy from BR1'); +# We should not be able to place a hold on a copy owned by a different branch. +is(copy_hold_permit_test($editor, $patron, "CONC51000636"), 0, 'Cannot place hold on copy from BR2'); + +# See if we can check out a copy owned by branch 4 out to the patron. +# This should succeed. +ok(!checkout_permit_test($patron, "CONC4300036"), 'Cannot checkout copy from BR1'); + +# We should not be able to checkout a copy owned by a different branch. +ok(!checkout_permit_test($patron, "CONC51000636"), 'Cannot checkout copy from BR2'); + +# 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'); + +# Do the checks again, all should pass. +is(patron_sip_test($patron->id()), 0, 'SIP says patron has no penalties'); + +# See if we can place a hold on a copy owned by BR1. +is(copy_hold_permit_test($editor, $patron, "CONC4300036"), 1, 'Can place hold on copy from BR1'); +# We should now be able to place a hold on a copy owned by a different branch. +is(copy_hold_permit_test($editor, $patron, "CONC51000636"), 1, 'Can place hold on copy from BR2'); + +# See if we can check out a copy owned by branch 4 out to the patron. +# This should succeed. +ok(checkout_permit_test($patron, "CONC4300036"), 'Can checkout copy from BR1'); + +# We should not be able to checkout a copy owned by a different branch. +ok(checkout_permit_test($patron, "CONC51000636"), 'Can checkout copy from BR2'); + +$script->logout(); diff --git a/Open-ILS/src/perlmods/live_t/15-lp1533329-opt-in.t b/Open-ILS/src/perlmods/live_t/15-lp1533329-opt-in.t new file mode 100644 index 0000000000..31b69ab246 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/15-lp1533329-opt-in.t @@ -0,0 +1,174 @@ +#!perl + +use Test::More tests => 12; + +diag("Test checking for, creating, and restricting patron opt-in."); + +use constant WORKSTATION_NAME => 'BR1-test-12-lp1533329-opt-in.t'; +use constant WORKSTATION_LIB => 4; # BR1, a branch of SYS1 +use constant PATRON_LIB => 6; # BR3, a branch of SYS2 +use constant PATRON_SYS => 3; # SYS2 +use constant SYS_DEPTH => 1; # depth of "System" org type +use constant PATRON_BARCODE => '99999359616'; + +use strict; use warnings; + +use OpenILS::Utils::TestUtils; +use OpenILS::Utils::CStoreEditor qw/:funcs/; +use OpenILS::Utils::Fieldmapper; + +my $script = OpenILS::Utils::TestUtils->new(); +$script->bootstrap; + +our $U = "OpenILS::Application::AppUtils"; + +my $e = new_editor(xact => 1); +$e->init; + +# initialize a new aous object for insertion into the db +sub new_org_setting { + my ($org_unit, $name, $value) = @_; + my $set = Fieldmapper::actor::org_unit_setting->new(); + $set->org_unit($org_unit); + $set->name($name); + $set->value($value); + return $set; +} + +sub opt_in_enabled { + my $resp = $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.org_unit_opt_in.enabled' + ); + return $resp; +} + +# do an opt-in check +sub opt_in_check { + my ($authtoken, $usr_id) = @_; + my $resp = $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.org_unit_opt_in.check', + $authtoken, $usr_id); + return $resp; +} + +unless(opt_in_enabled()) { + BAIL_OUT('cannot test opt-in unless enabled in opensrf.xml'); +} + +#---------------------------------------------------------------- +# 1. Login, register workstation, get authtoken. +#---------------------------------------------------------------- +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff'}); +ok( + $script->authtoken, + 'Have an authtoken' +); +my $ws = $script->register_workstation(WORKSTATION_NAME,WORKSTATION_LIB); +ok( + ! ref $ws, + 'Registered a new workstation' +); +$script->logout(); +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff', + workstation => WORKSTATION_NAME}); +ok( + $script->authtoken, + 'Have an authtoken associated with the workstation' +); + +#---------------------------------------------------------------- +# 2. Set org.patron_opt_boundary for SYS2, so that BR1 is outside +# the boundary. +#---------------------------------------------------------------- +$e->xact_begin; +my $boundary = new_org_setting(PATRON_SYS, 'org.patron_opt_boundary', SYS_DEPTH); +my $boundary_stat = $e->create_actor_org_unit_setting($boundary); +ok($boundary_stat, 'Opt boundary setting created successfully'); +$e->xact_commit; + +#---------------------------------------------------------------- +# 3. Check opt-in for test patron. It should return 0. +#---------------------------------------------------------------- +my $patron = $U->fetch_user_by_barcode(PATRON_BARCODE); +is( + opt_in_check($script->authtoken, $patron->id), + '0', + 'Opt-in check for non-opted-in patron correctly returned 0' +); + +#---------------------------------------------------------------- +# 4. Set org.restrict_opt_to_depth at SYS2, so that BR1 is +# outside SYS2's section of the tree at the specified depth (thus +# preventing opt-in). +#---------------------------------------------------------------- +$e->xact_begin; +my $restrict = new_org_setting(PATRON_SYS, 'org.restrict_opt_to_depth', SYS_DEPTH); +my $restrict_stat = $e->create_actor_org_unit_setting($restrict); +ok($restrict_stat, 'Opt restrict depth setting created successfully'); +$e->xact_commit; + +#---------------------------------------------------------------- +# 5. Check opt-in for test patron. It should return 2. +#---------------------------------------------------------------- +is( + opt_in_check($script->authtoken, $patron->id), + '2', + 'Opt-in check for patron at restricted opt-in library correctly returned 2' +); + +#---------------------------------------------------------------- +# 6. Remove the org.restrict_opt_to_depth setting for SYS2. +#---------------------------------------------------------------- +$e->xact_begin; +my $delete_restrict_stat = $e->delete_actor_org_unit_setting($restrict); +ok($delete_restrict_stat, 'Opt restrict depth setting deleted successfully'); +$e->xact_commit; + +#---------------------------------------------------------------- +# 7. Create opt-in for test patron. +#---------------------------------------------------------------- +my $opt_id = $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.org_unit_opt_in.create', + $script->authtoken, $patron->id, WORKSTATION_LIB); +ok($opt_id, 'Patron successfully opted in'); + +#---------------------------------------------------------------- +# 8. Check opt-in for test patron. It should return 1. +#---------------------------------------------------------------- +is( + opt_in_check($script->authtoken, $patron->id), + '1', + 'Opt-in check for opted-in patron correctly returned 1' +); + +#---------------------------------------------------------------- +# 9. Delete opt-in. +#---------------------------------------------------------------- +my $opt = $U->simplereq( + 'open-ils.cstore', + 'open-ils.cstore.direct.actor.usr_org_unit_opt_in.retrieve', + $opt_id +); +$e->xact_begin; +my $delete_opt_stat = $e->delete_actor_usr_org_unit_opt_in($opt); +ok($delete_opt_stat, 'Opt-in deleted successfully'); +$e->xact_commit; + +#---------------------------------------------------------------- +# 10. Remove opt boundary setting. +#---------------------------------------------------------------- +$e->xact_begin; +my $delete_setting_stat = $e->delete_actor_org_unit_setting($boundary); +ok($delete_setting_stat, 'Opt boundary setting deleted successfully'); +$e->xact_commit; + + diff --git a/Open-ILS/src/perlmods/live_t/16-acq-invoicing.t b/Open-ILS/src/perlmods/live_t/16-acq-invoicing.t new file mode 100644 index 0000000000..82f9ec0982 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/16-acq-invoicing.t @@ -0,0 +1,88 @@ +#!perl +use strict; use warnings; +use Test::More tests => 7; +use OpenILS::Utils::TestUtils; +use OpenILS::Utils::CStoreEditor qw/:funcs/; + +diag("Tests ACQ invoices"); + +my $script = OpenILS::Utils::TestUtils->new(); +$script->bootstrap; + +my $e = new_editor(); +$e->init; + +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff' +}); + +ok($script->authtoken, 'Have an authtoken'); + +my $invoice = Fieldmapper::acq::invoice->new; +$invoice->isnew(1); +$invoice->receiver(1); +$invoice->provider(1); +$invoice->shipper(1); +$invoice->inv_ident(rand()); +$invoice->complete('f'); + +my $entry = Fieldmapper::acq::invoice_entry->new; +$entry->isnew(1); +$entry->lineitem(3); +$entry->purchase_order(2); +$entry->inv_item_count(1); +$entry->phys_item_count(1); +$entry->cost_billed('25.00'); +$entry->actual_cost('25.00'); +$entry->amount_paid('25.00'); + +my $acq_ses = $script->session('open-ils.acq'); + +my $req = $acq_ses->request( + 'open-ils.acq.invoice.update', $script->authtoken, $invoice, [$entry]); + +$invoice = $req->recv->content; +$entry = $invoice->entries->[0]; + +is(ref $invoice, 'Fieldmapper::acq::invoice', 'Invoice created'); + +my $inv_debit = + $e->search_acq_fund_debit({invoice_entry => $entry->id})->[0]; + +isnt($inv_debit, undef, 'A fund_debit links to new invoice entry'); + +is($inv_debit->encumbrance, 't', + 'Debit is still encumbered after invoice create'); + +# Close the invoice. LP#1333254. +$invoice->complete('t'); +$invoice->ischanged(1); + +$req = $acq_ses->request( + 'open-ils.acq.invoice.update', $script->authtoken, $invoice); + +$invoice = $req->recv->content; + +is($invoice->complete, 't', 'Invoice is closed'); + +$inv_debit = $e->retrieve_acq_fund_debit($inv_debit->id); + +is($inv_debit->encumbrance, 'f', + 'Debit is disencumbered after invoice close'); + +# re-open the invoice +$invoice->complete('f'); +$invoice->ischanged(1); + +$req = $acq_ses->request( + 'open-ils.acq.invoice.update', $script->authtoken, $invoice); + +$invoice = $req->recv->content; + +$inv_debit = $e->retrieve_acq_fund_debit($inv_debit->id); + +is($inv_debit->encumbrance, 't', + 'Debit is re-encumbered when invoice is reopened'); +