From 2bb2d341a6156079fc10d734a66bbb291091afc0 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 1 May 2017 16:45:29 -0400 Subject: [PATCH] LP#1257915: add live_t tests And here's a test plan for humans: [1] Create a purchase order with, say, 3 lineitems and 2 copies on each of these. [2] Receive the first two lineitems outright. [3] Receive one of the copies on the last lineitem and cancel the other with a cancellation reason that's permanent (e.g., bad ISBN) rather than temporary (e.g., backordered). [4] Note that the purchase order's state remains 'on-order' [5] Apply the patch. [6] Repeat steps #1-4. This time, the PO's state should be 'received'. [7] Repeat steps #1-4, but this time, choose backordered as the cancellation reason. This time, the PO's state should remain 'on-order'. It should be noted that the patches for this bug do *not* retrospectively mark purchase orders as being received. Signed-off-by: Galen Charlton --- .../src/perlmods/live_t/22-acq-po-status.t | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Open-ILS/src/perlmods/live_t/22-acq-po-status.t diff --git a/Open-ILS/src/perlmods/live_t/22-acq-po-status.t b/Open-ILS/src/perlmods/live_t/22-acq-po-status.t new file mode 100644 index 0000000000..09ecda0e40 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/22-acq-po-status.t @@ -0,0 +1,64 @@ +#!perl +use strict; use warnings; +use Test::More tests => 11; +use OpenILS::Utils::TestUtils; +use OpenILS::Utils::CStoreEditor qw/:funcs/; +use OpenILS::Application::Acq::Order; + +diag("Tests ACQ purchase orders"); + +my $script = OpenILS::Utils::TestUtils->new(); +$script->bootstrap; + +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff' +}); + +my $e = $script->editor(authtoken=>$script->authtoken); +$e->xact_begin; + +ok($script->authtoken, 'Have an authtoken'); + +my $conn; # dummy for now +my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn); + +my $origpo = $e->retrieve_acq_purchase_order(2); +is($origpo->state, 'on-order', 'order starts at expected state') or + BAIL_OUT('order 2 does not have expected state'); + +my $origli3 = $e->retrieve_acq_lineitem(3); +my $origli4 = $e->retrieve_acq_lineitem(4); +my $origli5 = $e->retrieve_acq_lineitem(5); + +is($origli3->state, 'on-order', 'line item 3 starts at expected state') or + BAIL_OUT('line item 3 does not have expected state'); +is($origli4->state, 'cancelled', 'line item 4 starts at expected state') or + BAIL_OUT('line item 4 does not have expected state'); +is($origli5->state, 'cancelled', 'line item 5 starts at expected state') or + BAIL_OUT('line item 5 does not have expected state'); +is($origli4->cancel_reason, 1283, 'line item 4 starts at expected cancel_reason') or + BAIL_OUT('line item 4 does not have expected cancel_reason'); +is($origli5->cancel_reason, 1, 'line item 5 starts at expected cancel_reason') or + BAIL_OUT('line item 5 does not have expected cancel_reason'); + +my $ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2); +is($ret->state, 'on-order', 'order cannot be received (yet)'); + +OpenILS::Application::Acq::Order::receive_lineitem($mgr, 3, 1); +my $li = $e->retrieve_acq_lineitem(3); +is($li->state, 'received', 'line item 3 received'); + +$ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2); +is($ret->state, 'on-order', 'order still cannot be received'); + +$li = $e->retrieve_acq_lineitem(4); +$li->cancel_reason(2); # this one has keep_debits = false, i.e., we don't expect + # this one to ever show up +$e->update_acq_lineitem($li); + +$ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2); +is($ret->state, 'received', 'LP#1257915: order now received'); + +$e->rollback; -- 2.43.2