From 511950993626a70b5aa68b90995f0a363046b60a Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 8 Jan 2022 14:02:03 -0500 Subject: [PATCH] LP1883171 & LP1940663: Modify Perl live test for aci update chagnes Modify the existing tests to check the new return values for success and failure counts. Add additional tests for updating a batch of 10 items where half should fail and half should succeed. This work was sponsored by NOBLE. Signed-off-by: Jason Stephenson --- .../src/perlmods/live_t/lp1883171-copy-inventory.t | 59 +++++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/live_t/lp1883171-copy-inventory.t b/Open-ILS/src/perlmods/live_t/lp1883171-copy-inventory.t index 19dbeeb131..a745939ba0 100755 --- a/Open-ILS/src/perlmods/live_t/lp1883171-copy-inventory.t +++ b/Open-ILS/src/perlmods/live_t/lp1883171-copy-inventory.t @@ -251,8 +251,8 @@ my $resp = $U->simplereq( {copy_list=>[$copies->[0]->id()]} ); is( - $resp, - '1', + $resp->[0], + 1, 'Update copy inventory succeeded' ); @@ -322,9 +322,15 @@ $resp = $U->simplereq( $authtoken, {copy_list=>[$copies->[0]->id()]} ); -ok( - ref $resp, - 'Update copy inventory should fail' +is( + $resp->[0], + 0, + 'Update copy inventory should have 0 success' +); +is( + $resp->[1], + 1, + 'Update copy inventory should have 1 failure' ); # Make the second one float and it should succeed. $fcopy = $copies->[1]; @@ -339,8 +345,8 @@ if ($editor->update_asset_copy($fcopy)) { {copy_list=>[$fcopy->id()]} ); is( - $resp, - '1', + $resp->[0], + 1, 'Update inventory for floating copy' ); } else { @@ -348,7 +354,44 @@ if ($editor->update_asset_copy($fcopy)) { BAIL_OUT('Set copy floating failed'); } -# We could run 35 or 36 tests depending on what we find in the +# Test a batch update where some succeed and some fail. +$resp = $editor->search_asset_copy([ + {circ_lib => BR2_ID, status => 0, floating => undef}, + {limit => 5, idlist => 1} +]); +ok( + $resp && scalar(@{$resp}) == 5, + 'Got 5 copies from branch 2' +); +undef($copies); +push(@{$copies}, @{$resp}); +$resp = $editor->search_asset_copy([ + {circ_lib => BR1_ID, status => 0}, + {limit => 5, idlist => 1} +]); +ok( + $resp && scalar(@{$resp}) == 5, + 'Got 5 copies from branch 1' +); +push(@{$copies}, @{$resp}); +$resp = $U->simplereq( + 'open-ils.circ', + 'open-ils.circ.circulation.update_copy_inventory', + $authtoken, + {copy_list=>$copies} +); +is( + $resp->[0], + 5, + 'Updated inventory on 5 copies' +); +is( + $resp->[1], + 5, + 'Did not update inventory on 5 copies' +); + +# We could run 36 or more tests depending on what we find in the # database, so we don't specify a number of tests. done_testing(); -- 2.11.0