LP#161970 Transfer ACQ lineitem Perl live test
authorBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 17:54:10 +0000 (13:54 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 17:54:10 +0000 (13:54 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/live_t/22-acq-li-transfer.t [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/live_t/22-acq-li-transfer.t b/Open-ILS/src/perlmods/live_t/22-acq-li-transfer.t
new file mode 100644 (file)
index 0000000..8905de6
--- /dev/null
@@ -0,0 +1,75 @@
+#!perl
+use strict; use warnings;
+use Test::More tests => 7; 
+use OpenILS::Utils::TestUtils;
+use OpenILS::Application::AppUtils;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+my $U = 'OpenILS::Application::AppUtils';
+
+diag("Tests ACQ order li->bib transfers");
+
+use constant LI_ID => 3;
+use constant SOURCE_BIB => 3;
+use constant TARGET_BIB => 110;
+
+my $script = OpenILS::Utils::TestUtils->new();
+$script->bootstrap;
+
+my $e = new_editor();
+$e->init;
+
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff'
+});
+
+my $auth = $script->authtoken;
+
+ok($auth, 'Have an authtoken');
+
+my $acq = $script->session('open-ils.acq');
+
+my $li = $acq->request(
+    'open-ils.acq.lineitem.transfer_to_bib', $auth, LI_ID, TARGET_BIB
+)->recv->content;
+
+isnt($li, undef, 'Transfer API returns a value');
+
+isnt(ref($li), 'HASH', 'Transfer API returns a non-Event value');
+
+is($li->eg_bib_id, TARGET_BIB, 'Lineitem points to new bib record'); 
+
+my $lids = $e->search_acq_lineitem_detail([
+    {lineitem => LI_ID},
+    {   flesh => 2, 
+        flesh_fields => {
+            acqlid => ['eg_copy_id'],
+            acp => ['call_number']
+        }
+    }
+]);
+
+is($lids->[0]->eg_copy_id->call_number->record, 
+    TARGET_BIB, 'Call number object transfered to target bib');
+
+# Now transfer it back
+$li = $acq->request(
+    'open-ils.acq.lineitem.transfer_to_bib', $auth, LI_ID, SOURCE_BIB
+)->recv->content;
+
+is($li->eg_bib_id, SOURCE_BIB, 'Lineitem points back to source record'); 
+
+$lids = $e->search_acq_lineitem_detail([
+    {lineitem => LI_ID},
+    {   flesh => 2, 
+        flesh_fields => {
+            acqlid => ['eg_copy_id'],
+            acp => ['call_number']
+        }
+    }
+]);
+
+is($lids->[0]->eg_copy_id->call_number->record, 
+    SOURCE_BIB, 'Call number object transfered back to source bib');
+