LP1952931 ASN shipment notifiation Perl Test
authorBill Erickson <berickxx@gmail.com>
Mon, 6 Dec 2021 19:32:06 +0000 (14:32 -0500)
committerBill Erickson <berickxx@gmail.com>
Tue, 4 Jan 2022 16:00:35 +0000 (11:00 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t

index fcf8b0c..a5c728a 100755 (executable)
@@ -1,11 +1,13 @@
 #!/usr/bin/perl
 use strict; use warnings;
+use Data::Dumper;
 use OpenILS::Utils::TestUtils;
 use OpenILS::Utils::CStoreEditor (':funcs');
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Application::Acq::EDI;
+$Data::Dumper::Indent = 0;
 
-use Test::More tests => 5;
+use Test::More tests => 3;
 
 diag("Tests EDI Shipment Notifications");
 
@@ -68,15 +70,16 @@ sub create_seed_data {
     my $addr = $e->retrieve_actor_org_address(BR1_ADDR_ID);
     $addr->san(BR1_SAN);
 
-    BAIL_OUT("Could not apply SAN to BR1 " . $e->die_event)
+    BAIL_OUT("Could not apply SAN to BR1 " . Dumper($e->die_event))
         unless $e->update_actor_org_address($addr);
     
     $edi_account = Fieldmapper::acq::edi_account->new;
+    $edi_account->owner(BR1_ID);
     $edi_account->provider(PROVIDER_ID);
     $edi_account->host("example.org");
     $edi_account->label("ASN TEST");
 
-    BAIL_OUT("Could not create EDI account " . $e->die_event)
+    BAIL_OUT("Could not create EDI account " . Dumper($e->die_event))
         unless $e->create_acq_edi_account($edi_account);
 }
 
@@ -90,9 +93,11 @@ sub create_po {
     my $resp = $U->simplereq('open-ils.acq', 
         'open-ils.acq.purchase_order.create', $script->authtoken, $po);
 
-    BAIL_OUT("Failed to create PO: $resp") if $U->is_event($resp);
+    BAIL_OUT("Failed to create PO: " . Dumper($resp)) if $U->is_event($resp);
 
-    $po_id = $resp->purchase_order->id;
+    $po_id = $resp->{purchase_order}->id;
+
+    ok($po_id, "Created Purchase Order");
     
     my $li = Fieldmapper::acq::lineitem->new;
     $li->purchase_order($po_id);
@@ -107,29 +112,37 @@ sub create_po {
     my $li_id = $U->simplereq('open-ils.acq',
         'open-ils.acq.lineitem.create', $script->authtoken, $li);
 
-    BAIL_OUT("Failed to create Lineitem: $li_id") if $U->is_event($li_id);
+    BAIL_OUT("Failed to create Lineitem: " . Dumper($li_id)) if $U->is_event($li_id);
+
+    ok($li_id, "Created Lineitem");
 
     my $lid = Fieldmapper::acq::lineitem_detail->new;
-    $lid->lineitem($lid);
+    $lid->isnew(1);
+    $lid->lineitem($li_id);
     $lid->fund(FUND_ID);
     $lid->owning_lib(BR1_ID);
     $lid->location(LOCATION_ID);
 
     $resp = $U->simplereq('open-ils.acq',
-        'open-ils.acq.lineitem_detail.cud.batch', $script->authtoken, $lid);
+        'open-ils.acq.lineitem_detail.cud.batch', $script->authtoken, [$lid]);
+
+    BAIL_OUT("Failed to create Lineitem Detail: " . Dumper($resp)) if $U->is_event($resp);
 
-    BAIL_OUT("Failed to create Lineitem Detail: $resp") if $U->is_event($resp);
+    ok($resp->{lid} == 1, 'Created a lineitem detail');
 
-    my $attr = $e->search_acq_lineitem_marc_attr_definition({
-        lineitem => $li_id, attr_name => 'isbn'})->[0];
+    my $attr = $e->search_acq_lineitem_attr({
+        lineitem => $li_id, 
+        attr_name => 'isbn',
+        attr_type => 'lineitem_marc_attr_definition'
+    })->[0];
 
     BAIL_OUT("Lineitem creation did not create an ISBN attribute")
         unless $attr;
 
     $attr->order_ident('t');
 
-    BAIL_OUT("Failed apply order_ident to ISBN attr: " . $e->die_event)
-        unless $e->update_acq_lineitem_marc_attr_definition($attr);
+    BAIL_OUT("Failed apply order_ident to ISBN attr: " . Dumper($e->die_event))
+        unless $e->update_acq_lineitem_attr($attr);
 }
 
 sub process_asn {
@@ -162,7 +175,7 @@ ASN
     my $in = OpenILS::Application::Acq::EDI->process_retrieval(
         $ASN, "remote-file-name",
         OpenILS::Application::Acq::EDI->remote_account($edi_account),
-        $edi_acctount
+        $edi_account
     );
 
     # TODO test presence of shipment notification and entry